BackboneJS與Rails

jieforest發表於2012-09-17
Earlier this summer I had the opportunity to speak at a fantastic regional conference,Magma Rails.

The location is not what you might expect, being an off-the-beaten-path part of Mexico. There are no crowds of American and European touristas — well none outside of the crowd of non-Mexican rubyists.

On the other hand, you are deep in Mexico, midway along the Pacific coast, with nice beaches and lovely mountains. The sponsors, Mexican rubyists, and people in general are genial and engaging, making us touristas feel right at home.

The original talk topic was going to be Cucumber, instead I opted1 for talk titled Getting started with Backbone and Rails, 25 things you need to know (ShowOff slides). The talk has a fair bit of code, drawn from a working example. The example app was going to be released after the conference…

…and, long story short, that never2 happened…

…until now!

[b]An example app[/b]

The app is incomplete, lacking tests, and written for clarity not conciseness. All of the JavaScript. code is written in CoffeeScript3. The Rails code is mostly scaffolding. You can find the source on github.

Over roughly 22 commits, the app is transformed into a one-page Backbone app that:

1. shows a list of movies
2. allows drilling into a specific movie
3. can add a new movie
4. can deleted an existing movie
5. sorts the list of movies
6. allows deep links directly to a specific movie

The app demonstrates how to structure a Backbone app for use with the asset pipeline, how to write views, handle forms, and interact with models, and how to fit Backbone in with Rails.


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/301743/viewspace-743726/,如需轉載,請註明出處,否則將追究法律責任。

相關文章