Compiled REPORTS
Compiled REPORTS
js
Overview of backbone.js
Prepared by:
Stephen Frias
&
Nouie Boy Frias
• BackboneJS is a lightweight JavaScript library that allows to develop and structure the
client side applications that run in a web browser. It offers MVC framework which
abstracts data into models, DOM into views and bind these two using events.
• History − BackboneJS was developed by Jeremy Ashkenas and was initially released on
October 13th, 2010.
• -BackboneJS allows developing of applications and the frontend in a much easier way by
using JavaScript functions.
• -BackboneJS provides various building blocks such as models, views, events, routers and
collections for assembling the client side web applications.
• -BackboneJS is a simple library that helps in separating business and user interface logic.
• -It is free and open source library and contains over 100 available extensions.
• -It acts like a backbone for your project and helps to organize your code.
• -It manages the data model which includes the user data and displays that data at the
server side with the same format written at the client side.
• -BackboneJS has a soft dependency with jQuery and a hard dependency with
Underscore.js.
• -It allows to create client side web applications or mobile applications in a wellstructured
and an organized format.
• The BackboneJS gives a structure to the web applications that allows
to separate business logic and user interface logic. In this chapter, we
are going to discuss the architectural style of the BackboneJS
application for implementing user interfaces. The following diagram
shows the architecture of BackboneJS :
The architecture of BackboneJS contains the
following modules :
HTTP Request
Router
View
Events
Model
Collection
Data Source
Setting backbone.js
environment setup
Prepared by:
Demar Pahid
• BackboneJS is very easy to setup and work. This chapter will discuss
the download and setup of the BackboneJS Library.
Development Version − Right click on this button and save as and you get
the full source JavaScript library.
Production Version − Right click on this button and save as and you get the
Backbone-min.js library file which is packed and gzipped.
Edge Version − Right click on this button and save as and you get an
unreleased version, i.e., development is going on; hence you need to use it
at your own risk.
Dependencies
Prepared By:
Mark Jed Neis
&
James Lloyd Eag;le Montejo
Backbone.js Views
• The backbone.js Views specify how your data looks like. They
represent model’s data to the users. they can be used with any
Javascript template library. They handle users input events, bind
events and methods, render model and collection and interact with
users.
Index Method Description
Report of :
JOHN ADRIAN D. MANTUA
&
LOUISE ALBERT ROFLO
S.No.Events & Description
1
"add"(model, collection, options)
It used when a model is added to the collection.
2
"remove"(model, collection, options)
It removes a model from the collection.
3
"reset"(collection, options)
It is used to reset the collection content.
4
"sort"(collection, options)
It is used when a collection needs to resorted.
5
"change"(model, options)
It is used when changes are to be made to a model's attributes.
6
"change:[attribute]"(model, value, options)
It is used when there is an update in an attribute.
7.
"destroy"(model, collection, options)
It fires when the model is destroyed.
8
"request"(model_or_collection, xhr, options)
It is used when a model or a collection starts requesting to the server.
9
"sync"(model_or_collection, resp, options)
It is used when a model or a collection is synced successfully with the server.
10
"error"(model_or_collection, resp, options)
It activates when there is an error in requesting to the server.
11
"invalid"(model, error, options)
When there is a fail in model validation, it returns invalid.
12
"route:[name]"(params)
When there is a specific route match, this event can be used.
13
"route"(route,params)
It is used when there is a match with any route.
14
"route"(router, route, params)
It is used by history when there is a match with any route.
15
"all" It fires for all the triggered events by the passing event name as the first argument.
Backbone.JS - Model
• On the other hand, arrays are an ordered collection that can hold data of
any type. In JavaScript, arrays are created with square brackets [...] and
allow duplicate elements.
• Until ES6 (ECMAScript 2015), JavaScript objects and arrays were the
most important data structures to handle collections of data. The
developer community didn't have many choices outside of that. Even so,
a combination of objects and arrays was able to handle data in many
scenarios.
• For the templates we match a template name with a function that will
generate javascript elements and append the resulting DOM to the div
where the application lives. This functionality in a real router would be taken
over by the templating engine. For the routes, we just do the mapping
between a route path and the corresponding template.
• What is left is to have the logic to detect changes in the URL and resolve
them to render the template. To do so, listen for the load & hashchange
events. The former fires then a document is loaded, and the latter when the
URL hash changes.