Domanda

I'm writing basically a folder browser in JavaScript, that starts at some folder on my server and every time you click a file I want the server to send me back a list of all the folders in that directory... but the problem is I can't seem to figure out how to update my backbone collection with the new data returned by the server when i do this.model.save()... I see in my web inspector that the response is being sent, so how do I update a collection; flushing out all the old data and updating it with the new data that was returned by the server?

any help with this would be greatly appreciated.

È stato utile?

Soluzione

You are meaning collection.fetch. To do the server call:

this.collection.fetch();

To listen in the view the change:

this.collection.on('add', this.newModel);

Also in previous bakcbone version you could listen to the reset event instead of add. You could get more info about usage here: http://backbonejs.org/#Collection-fetch

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top