0👍
I look at this. It looks obtuse, but I try to compare backbone elements with django elements.
A backbone collection is the equivalent to a QuerySet object in Django.
Models in backbone (as in Django) only take data definition.
the router object is like the Django URL dispatcher.
views are scoped by the element they affect (instead of rendering the whole page like in django, they change a defined element in the document)
1👍
Models are the heart of any JavaScript application, containing the interactive data as well as a large part of the logic surrounding it: conversions, validations, computed properties, and access control.
Example:
Person = Backbone.Model.extend({
defaults: {
name: 'Fetus',
age: 0,
children: []
},
initialize: function(){
alert("Welcome to this world");
}
});
Backbone do not have the controller as in traditional mvc framework but use routers. Backbone routers are used for routing your applications URL’s. In the traditional MVC sense they don’t neccesarily fit the semantics
Example :
var AppRouter = Backbone.Router.extend({
routes: {
"/posts/:id": "getPost",
"*actions": "defaultRoute" // Backbone will try match the route above first
},
getPost: function( id ) {
// Note the variable in the route definition being passed in here
alert( "Get post number " + id );
},
defaultRoute: function( actions ){
alert( actions );
}
});
In backbone you don’t have the database connection etc but you use Rest interaction with a backed server
I suggest you to follow these screencast that will explain you exactly what is backbone :
https://peepcode.com/products/backbone-js
- [Answer]-Iterating through a data list and edit an object's attribute based on the list
- [Answer]-ViewDoesNotExist django