Initial backbone.js data fetch Initial backbone.js data fetch javascript javascript

Initial backbone.js data fetch


This bit of documentation is there to remind you that you should load all the data on the initial page load and use fetch for all the subsequent loads.

You can have code like this:

MyCollection = new Collection({some json data});

Much faster than a page load then a couple of request to load the data.


Im a bit confused on the wording of the doc as well, but fetch is the way to tell your Collection or Model to go the server and get the data via either your own sync function or Backbone.sync which already internally uses ajax and can pass the result along to your success or error function.

As far as Todos example you mentioned, thats how Collection is meant to work. It updates the models, then triggers 'refresh' event which may force your view to be re-rendered, like you said.

I highly recommend looking at Backbone.js code. Its very effectively documented and the flow of events and method calls is very easy to grasp due to that.