Backbone is a front-end JS code MVC framework, but it is not strictly the model, View, Controller (which I will answer in the example). It cannot replace Jquery and cannot replace the existing template library. Instead, it combines with these to build complex Web front-end interactive applications.
Backbone:
- force depends on underscore.js, so you must introduce underscore.js before introducing Backbone.js. Underscore.js is a utility library;
- does not enforce dependency on Jquery/zepto
- automatically updates the application's HTML based on changes to the model to help code maintenance;
- Promote client template use and avoid Embed HTML code in JavaScript.
In the next tutorial I will use backbone to implement a simple address book application, the specific page effect I have done:
Backbone Address Book Tutorial page
Address Book Function Analysis:
- Address Book page to add, modify, delete contacts (bulk delete), search for contacts
- Contact Change Click Save Unified Submit to Server
- Real-time display of contact number in the top right
Page MVC Partitioning:
- The views, models, and collections that are used by the
-
Page are unified under the namespace contact, which is:
var contacts = {Models: {}, Collections: {}, Views: {}};
Page two view (Mainview,memberview), a collection to hold the contact set, a model to store the contact models, namely:
Contact.Models.Member Contact.Collections.Member Contact.Views.Member
Tutorial start data directly with the browser Localstorage to store contacts, because the lower version of the browser does not support Localstorage, so here I use backbone.localStorage.js. Later will use Node.js for back-end support, so there will be node.js tutorials, but also use sea.js to dynamically load the JS library.
This is the end of today's tutorial, please wait!