Backbone.js and rails - BanLV

8
BACKBONE.JS and RAILS Name: Le Van Ban

description

 

Transcript of Backbone.js and rails - BanLV

Page 1: Backbone.js and rails - BanLV

BACKBONE.JS and RAILS

Name: Le Van Ban

Page 2: Backbone.js and rails - BanLV

What is Backbon.js?Why would you use Backbone.js?Component of backbone.jsHow to use backbone with rails?

Page 3: Backbone.js and rails - BanLV

What is Backbon.js?

• Backbone is a framework JS, a JavaScript library with a RESTfull Json interface

• Backbone was created by Jeremy Ashkenas.

Page 4: Backbone.js and rails - BanLV

Why would you use Backbone.js?

- Easier to build javascrip for web app - Easier to maintain

Code is clear Structure MVC

Page 5: Backbone.js and rails - BanLV

Component of backbone.js

Router

View: used to listen to events and react accordingly

Model: containing the interactive data

Collection: an ordered set of models

Page 6: Backbone.js and rails - BanLV

How to use backbone with rails?

Add “ gem 'rails-backbone' “ to GemfileInstall:

bundle installrails g backbone:installrails g scaffold Post title:string content:stringrake db:migrate

rails g backbone:scaffold Post title:string content:string

( rails g backbone:model - model and collection rails g backbone:router - views and templates )

Page 7: Backbone.js and rails - BanLV

DEMO

Page 8: Backbone.js and rails - BanLV

Tài liệu tham khảo

• http://backbonetutorials.com/• http://backbonejs.org/• https://github.com/codebrew/backbone-rails• http://perka.github.io/backbone-ui/