The Model responsibility is to store data and expose functionality to manipulate it. The Model in Backbone.js is just a data structure that acts as a model in the application. Once you have all the libraries in place, let’s start by explaining the first Backbone.js object – the Model. The following code example is a template for that HTML web page: Webpage Title Now that you have downloaded the libraries, you can create a small HTML file and add a script reference to all the files. jQuery: (recommended to use version >= 1.9.0).Underscore.js: (download version should be >= 1.5.0).You can download the libraries using the following links: Backbone.js also depends on jQuery when you extend its View object or when you use its Router object so don’t forget to download it as well. The reason that you will need Underscore.js is that Backbone.js has a dependency on the library and it uses many of Underscore.js utility functions underneath. Setting up the Environment for Backbone.jsīefore you start working with Backbone.js, you should download its latest version and also download Underscore.js and jQuery. Now that you know what Backbone.js offers, we can take a dive into Backbone components. The sync API is out of scope for this article. This API enables communication with the server, and the model and collection objects use it underneath to synchronize their data when you use their create/update/delete APIs. īackbone.js also includes an API called sync API that is exposed by Backbone.sync function. You can learn more about each of the objects in Backbone.js website. Events – enables to extend any object with event handlersĮach of the objects comes with its own APIs which enables many common development tasks.Routers – expose client-side routing mechanism.In its core, Backbone.js includes five main objects that the developer can extend with his/her own functionality: Backbone.js is a lightweight JavaScript library that enforces developers to organize their code in a clean and efficient manner and eases the development of SPAs. What is Backbone.js?īackbone.js is a Model-View-Whatever (MVW) library that was written by Jeremy Ashkenas, the creator of CoffeeScript and Underscore.js. While we won’t cover the ways Backbone.js can help you create SPAs, you can find more content about it in “Pro Single Page Application Development” (Apress) book or by searching online. In this article we will take a look at Backbone.js and how you can use some of its features. One of the popular libraries that help to create SPAs is Backbone.js. The popular SPA frameworks are AngularJS and Ember. One recommended way to create SPAs is by using libraries or frameworks that expose features such as routing, template engines and ways to communicate with the server. That means you can create RIAs using HTML, CSS and JavaScript and gain a lot of smart client qualities, such as being stateful and responsive. This shell is changed via JavaScript interactions made by the users, client-side template engines and client-side routing mechanisms. SPAs are web applications that include only one HTML page that acts as a shell to the whole application. In the past few years, we have also seen an emerging trend to build Single Page Applications (SPAs). These changes help web developers to build next generation rich internet applications (RIAs). Graphics, multimedia and device interactions are first class citizens in web applications and you don’t have to use plugins to create sophisticated features. Standards such as HTML5, ECMAScript and CSS3 are helping to design more responsive and interactive web applications.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |