Welcome to backbone.js, just as a name it’s the most important javascript library for you to develop
applications.
What is
Backbone.js?
Backbone.js is a
lightweight javascript library that allows to develop and structure the client
side applications that run in a web browser.
Backbone.js is a
library framework created by Jeremy Ashkenas.
It provides client-side application structure, it's kind of MVC(Master-view-controller)framework which focuses on the separation of concerns.Backbone.js also makes use of routers which is helpful in creating single-page applications
Following are the features of Backbone
·
Backbone
provides different types of building blocks like models, views, events, routers.
·
Backbone
makes your code simple and organized.
·
Backbone
allows developers to create client-side web applications.
·
Backbone
is open-source which contains a free library.
·
Backbone.js
allows developers to create client-side web applications.
·
Backbone
is open-source which contains a free library.
·
Backbone
allows developers to create client-side web applications or mobile applications
in an organized format.
Why do you need
Backbone.js?
To build
something without structure is never a good idea. Backbone has a layer set of the library that helps you to give a great structure to your
application.Backbone.js gives structure to the web application by providing models
with key-value building and custom events, collections with a rich API of
enumerable functions, views. it's well documented and store data in models
What is the use of Backbone.js?
Backbone.js is
something that almost every developer will come to experience, programming is a
matter of abstraction. The better the code the better the abstraction.worked
with javascript for a while and have a good previous programming expression and
you prioritize a good design and architecture you will surely gonna use
backbone.
Installation of Backbone.js
Models in Backbone.js
Models are the heart of any JavaScript application. The authors of backbone.js have quite a clear definition of what they believe the model represents in backbone.js
Creating a model
[code]. var UserModel = Backbone.Model.extend({
urlRoot: '/user',
defaults: {
name: '',
email: ''
});
var user = new UserModel();
// Notice that we haven't set an `id`
var userDetails = {
name: 'Bhawna',
email: 'tiwaribhawna29mar@gmail.com'
};
// POST /user with a payload of {name:Bhawna, email: 'tiwaribhawna29mar@gmail.com'}
// The server will save the data and return a response
containing the new `id`
user.save(userDetails, {
success: function (user) {
alert(JSON.stringify(user));
}
Table should now have the values
1, 'Bhawna', 'tiwaribhawn29mar@gmail.com'
Retrieve a model
Now that we have
saved a new user model, we can now retrieve it from the server, we can clearly
see the id is 1 in the above example.
Backbone.js
collection
A collection is an ordered set of models .it handles the loading and saving of new models to the server.in Backbone.js you can create your own collections with the help of the backbone’s collection class.
extend |
Extends the backbone’s collection class to create your own collection |
Initialize |
Initialize to define functions to create a model class |
Models |
An array of models created inside the collection |
Add |
Used to add model or array of models into the collection |
Sync |
Specifies the state of the model and uses the backbone.sync |
toJSON |
Return the copy of the attribute of the model |
Remove |
Remove model and array from the collection |
Push |
Take the array of models and push the models to the collection |
Get |
Used to retrieve the model from a collection by using id |
Set |
Used to update the collections with a set of items in a model. |
Create |
Creates a new instance in the model of the collection. |
Pop |
Take the array of models and remove the models from the collections |
Where |
Used to display the model by using a matching attribute in the
collection. |
fetch |
Uses the sync method to extract data from the model in the
collection. |
So, with backbone.js you are free to define your events with Backbone.events it is designed as such that you can mix it with any javascript object.
Popular
tools that integrate with Backbone.js
· Jscrambler
· Sentry
· Firebase
· Marionette
· Acrobatic
Companies
using Backbone
In nutshell, we can describe Backbone as the following
· For its
best JavaScript structure
· Use of
models
· Very simple
to use
· Flexible
· Fast to
pick up
· Open source
· Easy API
So by now, we have covered the basics to start with
backbone.js, to know and master kindly visit our website for the detailed
course
http://skillbakery.com/courses/master-backbone-js.html
Happy Learning
No comments:
Post a Comment