开发者

What is the best way to implement a parent applications controller or namespace controller in backbone.js?

开发者 https://www.devze.com 2023-02-13 04:46 出处:网络
Example apps like James Yu\'s (http://www.jamesyu.org/2011/01/27/cloudedit-a-backbone-js-tutoria开发者_如何学运维l-by-example/) provide excellent examples of how to integrate rails with backbone, but

Example apps like James Yu's (http://www.jamesyu.org/2011/01/27/cloudedit-a-backbone-js-tutoria开发者_如何学运维l-by-example/) provide excellent examples of how to integrate rails with backbone, but what if you want 10 controllers? or 30?


I am having trouble understanding what exactly your question is. We are building a backbone.js-based client for a Rails 3 backend. We are new to backbone.js too, but our app structure conforms similarly to the link you referenced:

index.html
js
+- app.js
+- controllers
  +- controller.js
  +- controller1.js
  ...
  +- controllern.js

where we augment the Backbone.Controller object with a few methods and strategies specific to our app.

In general, each controller has its own set of client-side routes that its responsible for and is very focused on just those. We use a minimum number of routes to minimize cases where we have to support bookmarking which would mean we'd have to spin up the whole app again.

Your client does not have to mirror the server's view of the world. Best practice is to customize the experience for the client application and to compartmentalize server dependencies.

Really not sure if this answers your question, but since you have no answer so far...

0

精彩评论

暂无评论...
验证码 换一张
取 消