Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>this is a good question. Though, Backbone isn't taking position on how you should organize your code.</p> <p>So, the real answer is: it depends.</p> <p>It depends on the need of your application and how you're used to program.</p> <p>If you want an overview of some best practice, I'd refer you to the Backbone Boilerplate project: <a href="https://github.com/tbranyen/backbone-boilerplate" rel="nofollow">https://github.com/tbranyen/backbone-boilerplate</a></p> <p>This project is pretty solid, and really helped me out when starting.</p> <p>Then, to answer your question (this may feel opiniated, and it is indeed):</p> <p><strong>1</strong>: Backbone is mostly an MV* framework (Model-View-Whatever). Controller logic mostly live into Backbone view, and this is OK for front end developpement as logic is often really tied to the UI (as we are mostly coding interfaces). Backbone isn't coming built in with controller, but if you prefer this type of organization, just build your own.</p> <p><strong>2</strong>: Urls depends on your need. If you're fetching a full collection, set it up on the collection, if you're only fetching (or probably saving) one model, set it on the model. These too live well together.</p> <p><strong>3</strong>: About Router, if you're building multiple pages/sections on your app, use them. But beware of not using <code>routes</code> as <code>action</code> as you would do in RESTful APIs, this will most of the time brings problem eventually (user press back button, etc). So, use routes if you want to manage pages.</p> <p>Hope this help !!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload