Reputation: 1656
I want to synchronise my collection each time an item is added.
So if user adds an item in another browser window - the server still sends us valid data.
And so... I got stuck! I read the docs a couple of times, but still can't undersand:
which method sends the data to server?
which method parses items from server's response and puts them into the collection?
Upvotes: 0
Views: 298
Reputation: 74176
model.save([attributes], [options]) :
Save a model to your database (or alternative persistence layer), by delegating to Backbone.sync.
model.parse(response) or collection.parse(response):
parse is called whenever a model's data is returned by the server, in fetch, and save. The function is passed the raw response object, and should return the attributes hash to be set on the model. The default implementation is a no-op, simply passing through the JSON response. Override this if you need to work with a preexisting API, or better namespace your responses.
Upvotes: 1