14
Backbone.js Client-side MVC framework

Backbonejs

  • Upload
    sam-lee

  • View
    266

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Backbonejs

Backbone.jsClient-side MVC framework

Page 2: Backbonejs

Backbone.js is…

Model/View/Controller Javascript framework

Structure provider

RESTful JSON Connector

Hash-Routing engine

Event-driven

LightWeight (6.3kb packed & gzipped)

Hard dependency on Underscore

(http://underscorejs.org/)

Page 3: Backbonejs

Backbone.js is not…

DOM selector

Effect tool kit

All in one package

Page 4: Backbonejs

Benefit ?

Backbone provides an easy way to organize your code by

its MVC pattern.

Easy to create an one page application.

Focus on one thing.

Page 5: Backbonejs

The Model

Page 6: Backbonejs

The Model

Easy to auto generate

Holds data better then the DOM

Throws data change event (add, delete, sync, sort …)

Can connect to a URL to populate from or persist to server

(Follow CRUD method or need to override sync function)

Page 7: Backbonejs

The Collection

Page 8: Backbonejs

The Collection

Easy to auto generate

For bulk handling model objects

Throw data change event .

Can connect to a URL to populate from server.

Query functions.

Page 9: Backbonejs

The View

Page 10: Backbonejs

The View or Controller…

Connect View and Model/Collection

Delegate DOM events

Subscribs Model/Collection change events

Page 11: Backbonejs

The Routing-engine

Page 12: Backbonejs

The Routing-engine

Useful to initiate application state

ex: window.location.hash = “start”;

Enable go back/forward browser functionality.

Makes application states bookmarkable!

Page 13: Backbonejs

Demo : TodoBackbone.js official example

Page 14: Backbonejs

Q&A