Backbone.js Тест Upwork

What is Backbone.sync used for?

When Backbone wants to save or read a model to the server it calls out a function called Backbone.sync.
When Backbone wants to save or read a view to the server it calls out a function called Backbone.sync.
When Backbone wants to save or read a event to the server it calls out a function called Backbone.sync.
All of the above

Which of the following tags are used to specify templates?

<% %/>
<% %>
<%></%>
<%= %>

How can you use Underscore Templates in Backbone.js Views?

First, create an underscore template
Create div for el property of the view
Compile the template using underscore
Load the compiled HTML into Backbone “el”
All of the above

How can a set of models be retrieved from the server and into the collection when they arrive?

collection.retrive()
collection.get()
collection.getJSON(url)
collection.fetch()

How can you retrieve a set of models from the server and set them to the collection when they arrive?

collection.remove()
collection.get()
collection.add()
collection.fetch()

Which code creates a template in Backbone.js?

<script type="text/template" id="website-list-template">
<table>
  <thead>
    <tr>
      <th>Name</th>
      <th>Aboutme</th>
      <th>Portfolio</th>
    </tr>
  </thead>
  <tbody>
    <% _.each(pages, function(web) { %>
      <tr>
        <td><% web.get{'name'} %></td>
        <td><% web.get{'aboutme'} %></td>
        <td><% web.get{'portfolio'} %></td>
      </tr>
    <% }); %>
  </tbody>
</table>
</script>

<script type="text/template" id="website-list-template">
<table>
  <thead>
    <tr>
      <th>Name</th>
      <th>Aboutme</th>
      <th>Portfolio</th>
    </tr>
  </thead>
  <tbody>
    <% _.each(pages, function(web) { %>
      <tr>
        <td><%= web.get('name') %></td>
        <td><%= web.get('aboutme') %></td>
        <td><%= web.get('portfolio') %></td>
      </tr>
    <% }); %>
  </tbody>
</table>
</script>

<script type="text/template" id="website-list-template">
<table>
  <thead>
    <tr>
      <th>Name</th>
      <th>Aboutme</th>
      <th>Portfolio</th>
    </tr>
  </thead>
  <tbody>
    <% _.each(pages, function(web) { %>
      <tr>
        <td><%= web.get[name] %></td>
        <td><%= web.get[aboutme] %></td>
        <td><%= web.get[portfolio] %></td>
      </tr>
    <% }); %>
  </tbody>
</table>
</script>

<script type="text/template" id="website-list-template">
<table>
  <thead>
    <tr>
      <th>Name</th>
      <th>Aboutme</th>
      <th>Portfolio</th>
    </tr>
  </thead>
  <tbody>
    <each(pages, function(web) {
      <tr>
        <td><%= web.get('name') %></td>
        <td><%= web.get('aboutme') %></td>
        <td><%= web.get('portfolio') %></td>
      </tr>
    <% }); %>
  </tbody>
</table>
</script>

Which of the following libraries can be used for defining Backbone template?

underscore
lodash
without library
Non of these.

Which of the following are Backbone Building Blocks? (choose all that apply)
Note: There may be more than one right answer.

Collection
Hash
Router
State

Which of the following types can be used in templates?

JSON
String
Number
All of the above

Which of the following properties can be used for manipulating DOM element?

element
el
id
class

 In Backbonejs, how can you change templates of a view on the fly?

@company_location= new window.ArtistLocationForm({templates: JST["template/new_company_location"]})

render: function(){
  var templateFn = this.option.template || this.template;
  this.$el.html(templateFn(this.model.attributes));
  return this;
}

render: function(){
  var templateFn = this.options.template || this.template;
  this.$el.html(templateFn(this.model.attributes));
  return this;
}

@company_location= new window.ArtistLocationForm({template: JST["templates/new_company_location"]})


Views are based on ____ templates that provide layouts for rendering?

Model
View
Controller
Collection

Which of the following options can be passed directly to the View?
Note: There may be more than one right answer.

element
el
class
id

Which method can be used for updating URL?

locationPath
location.href
navigate
pathname

Which of the following dependency must be added for Backbone.js setup?

<script src="/.../jquery.min.js"></script>
<script src="/.../angular.min.js"></script>
<script src =".../underscore-min.js" ></script>
<script src="/.../bootstrap.min.js"></script>

Which options will allow you to auto-bind a  BackboneJs view to existing element(s)?
Note: There may be more than one right answer.

$(".same-class").each(function(index,ele){
    var v=new MyView();
    $(ele).html(v.$el);
});

$(".same-class").each(function(index,ele){
    var v=new MyView({el:$(ele)});
});

var myView = Backbone.View.extend({  
el: '.class-name',
events: {
    'hover .button' : 'test'
},
test: function() {
    console.log('hi');
}
});

All of the above

What are the default Backbone.Sync handlers?

create,update,delete, read
create, update, patch, delete, read
create, update, trigger, delete, read
create, update, delete, get

Which of the following events is executed when the model validation fails?

isValid
invalid
validation
validationError

Which code is the Backbone.Events interface by default mixed into other Backbone components?

_.extend(View.prototype, Events, ( ... ));.
_.extend(View.prototype, Events, { ... });.
_.extend(View.prototype, Event, { ... });.
extend(View.prototype, Events, { ... });.

Trigger callbacks for the given event, or space-delimited list of events. Subsequent arguments to ___ will be passed along to the event callbacks?

stopListening
listenTo
once
trigger

To create a Collection class of your own, extend Backbone.Collection, providing instance properties, as well as optional classProperties to be attached directly to the collection's constructor function .........................

model
extend
previous
hasChanged

Removes all of the view's delegated events. Useful if you want to disable or remove a view from the DOM temporarily?

undelegateEvents
delegateEvents
removeview
events

Tell an object to stop listening to events. Either call stopListening with no arguments to have the object remove all of its registered callbacks ... or be more precise by telling it to remove just the events it's listening to on a specific object, or a specific event, or just a specific callback?
Note: There may be more than one right answer.

view.stopListening(event);
view.stopListening();
view.stopListening(model);
All of the above

You can remove all listeners on a particular object by using?

Instance_id.remove();
Instance_id.destroy();
Instance_id.off();
Instance_id.nulls();

Is it possible to subscribe on event when backbonejs view is removed from DOM?

No
Yes

What are the Events of Backbone JS? (choose all that apply)
Note: There may be more than one right answer.

var myModel = Backbone.Model.extend({ defaults : { title : ‘title’, description : ’description, owner : ‘anonymous’, date : ‘no date supplied’ } });
var object = {}; _.extend(object, Backbone.Events); object.on("fire ", function() { alert("Ouch, you just kick me"); }); object.trigger("fire");
var object = {}; _.extend(object, Backbone.Events); object.on("alert", function(msg) { alert("Trigger " + msg); }); object.trigger("alert", "event");
None of the above

How can an event be binded to an object?

object.on(event, callback)
object.trigger(event,callback)
object.listen(event,callback)
object.addListener(event,callback)

Which of the following syntax is valid in events for Backbone views?

“event css-selector”: “function”
“event element-id: “function”
“event”: “function id”
All of the above   

Which of the following libraries provide events for Backbone views? (choose all that apply)
Note: There may be more than one right answer.

Jquery
Angular
ZeptoJS
All of the above

"This method removes callback functions or all events from an object."
What option describes the above.

destroy
off
on
e.preventDefault

Which of the following events exists in Backbone Events System?

add
sync
invalid
All of the above

Which of the following route parameter's statement is correct of Router? (choose all that apply)
router.route(fun, name, [callback])
Note: There may be more than one right answer.

fun: May be routing function or regular expression
name: Name of the router parameter
callback: Name of the router, if callback argument is omitted
None of the above

Which of the following Collection methods is equivalent to instantiating a model with a hash of attributes?

create
new
init
initiate

In Backbone, ____ provide a way for you to connect URLs (either hash fragments, or real) to parts of your application. Any piece of your application that you want to be bookmarkable, shareable, and back-button-able needs an URL.

routers
trigger
events
templates

Which of the following will not continue and the attributes of the model will not be modified on the server?

.save()
.validate()
Both of the above
None of the above

Which statement is valid for setting initial values to the model attributes?

var
MyModel = Backbone.Model....({
init : {
"atribute1":
"atribute2":
}
});

var
MyModel = Backbone.Model....({
defaults: {
"atribute1":
"atribute2":
}
});

var
MyModel = Backbone.Model....({
attributes : {
"atribute1":
"atribute2":
}
});

var
MyModel = Backbone.Model....({
properties : {
"atribute1":
"value 1",
"atribute2":
"value 2",
}
});

Which of the following configuration options are available in Backbone.js?

InitialCopyDirection
modelSetOptions
boundAttribute
suppressThrows
All of the above

How does Backbone decide if it should use a POST/GET Request to the Server and what are the methods Backbone has Reserved for these Operations?

If we instantiate a model with an id, Backbone.js will automatically perform a GET request to the urlRoot + ‘/id’ using fetch() method. (conforming to RESTful conventions)
If the id attribute of the model is null, Backbone.js will send a POST request to the urlRoot of the server using save() method.
If the id attribute of the model is not null, Backbone.js will send a PUT request instead of a POST request using save() method.
If a model has an id we know that it exists on the server, so if we wish to remove it from the server we can call destroy() method. destroy will fire off a DELETE /user/id (conforming to RESTful conventions).
All of the above

The architecture of Backbone.js contains which of the following modules? (choose all that apply)
Note: There may be more than one right answer.

HTTP Request
Router
Events
Collection DB
Data Provider

Which of the following is not an Underscore utility function over Collections?

forEach
groupBy
length
size

BackboneJS fetches collection based on parameters using which code?

Genres.Collection = Backbone.Collection.extend({
    url: function() {
        return 'path to my json';
    },
    initialize: function(opts) {
       opts = opts || {};
       this.genre = opts.genre || 'rock';
    },
    parse: function(response){
        return response.data.genres[this.genre];
    }           
});

Genres.Collection = Backbone.Collection.extend({
    url: function() {
        return 'path to my json';
    },
    parse: function(response, genre){
        return response.data.genres[genre];
       // when I do: return response.data.genres.rock;
       // I get all artists from the genre "rock".
       // but I want the response to be based on the variable "genre"
    }           
});

Both of the above

None

Which code gets index by Backbone.Collection?
var Items = Backbone.Collection.extend({
  model : Item,
  url : "/items"
});
var items = new Items;
items.fetch();

items.getindex(1);
items.get(0);
items.at(0);
items.index(1);

Backbone.js Тест Answers часть 1

Backbone.js Тест Upwork 2019