heavily used for structuring desktop and server-side applications, but it's only been in recent years that come to being applied to JavaScript. ! As the majority of JavaScript developers currently using these patterns opt to utilize libraries such as Backbone.js for implementing an MVC/MV*-like structure.
things tend to get messy! ! Backbone provides a way to organize your code, by using the MVC pattern ! Only the View accesses the DOM (e.g. with jQuery, Dojo,…)
of JavaScript frameworks for creating MVC- like web applications, it's relatively lightweight and can be easily tested using third-party toolkits such as Jasmine or QUnit. Or ! Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
Simplify server-side persistence ! Decouple the DOM from your page's data ! Model data, views and routers in a succinct manner ! Provide DOM, model and collection synchronization
JavaScript application, containing the interactive data as well as a large part of the logic surrounding it: conversions, validations, computed properties, and access control.
initialize: function(){ alert("Hello Studio"); } }); var person = new Person; /*initialize() is triggered whenever you create a new instance of a model*/ Demos – model_basic.html, model_setter_getter.html, model_advance.html
} }); // The initialize function is always called when instantiating a Backbone View. // Consider it the constructor of the class. var search_view = new SearchView; Demos – view_basic.html, view_advance.html
set of models. var Song = Backbone.Model.extend({ initialize: function(){ console.log("Music is the answer"); } }); var Album = Backbone.Collection.extend({ model: Song }); Demo – collection.html
especially in rich list displays ! Adding or updating new items in lists ! Anywhere you need to add new complex content to the page ! Anything that requires client side HTML rendering Demo – template.html