- InitialCopyDirection
- modelSetOptions
- change Triggers
- boundAttribute
- suppressThrows
- converter
Q12. What is a converter in Backbone Js ?
Ans: When a model’s attribute is copied to an HTML element or when an HTML element’s value is copied into a model’s attribute, a function is called, this function is known as a converter in Backbone Js.
Q13. How are models attributes stored in Backbone.js?
Ans: In Backbone.js models attributes stored in a hash.
Q14. What is Router in Backbone? How do you create a Router with Backbone?
Ans: Backbone Router is used for routing client-side applications and connects them to actions and events using URLs. Backbone.Router is used to create a Router with Backbone.
Q15. How to Create a Model In Backbone js?
Ans: Creating a Model in Backbone Js
Person = Backbone.Model.extend({ initialize: function(){ alert("Welcome to Backbone Js"); } }); var person = new Person;
Q16. What is the function of toJSON?
Ans: toJSON is used for persistence, serialization and for augmentation before being sent to the server.
Q17. What Are “:params” And “*splats” In Dynamic Routing?
Backbone uses two styles of variables when implementing routes:
Ans:
- “:params” match any URL components between slashes. You can specify single fragment using “.params”
- “*splats” match any number of URL fragments after the query.
- Note that due to the nature of a “*splat”, it will always be the last variable in your URL as it will match any and all components.
- “*splats” or “:params” in route definitions are passed as arguments (in respective order) to the associated function.
- A route defined as “/:route/:action” will pass 2 variables (“route” and “action”) to the callback function.
Q18. What Is “el” Property Of Backbone.js View?
Ans: The “el” property references the DOM object created in the browser. Every Backbone.js view has an “el” property, and if it is not defined, Backbone.js will construct its own, which is an empty div element.
Q19. What Are The Configuration Options Available?
Ans: The configuration options available are:
- InitialCopyDirection
- modelSetOptions
- change Triggers
- boundAttribute
- suppressThrows
- converter
Q20. What is Collection in Backbone?
Ans: A collection is a set of models which binds events when the model has been modified in the collection. Collection contains a list of models that can be processed in the loop and supports sorting and filtering. When creating a collection, we can define what type of model that collection is going to have along with the instance of properties. Any event triggered on a model, which will also trigger on the collection in the model.
Q21. In a Backbone View, what is the use of setElement?
Ans: setElement function is used when Backbone view has to be applied to a different DOM element.