I have a hierarchy of categories. I use the jquery library for the hierarchy so that everything mixes up as the user wants. Then click "Save." Thus, the original hierarchy and the hierarchy that must be preserved can be completely different.
The hierarchy is presented as a collection, and I use parentIds to build the tree using the ol and li tags.
When the user clicks the "Save" button, I need to update all the elements of the collection with their new parentId and synchronize each with the server.
I am wondering if anyone has any tips on how to proceed here. I saw in the documentation for Backbone.sync "Use setTimeout to batch update quick updates in a single request." So, if I understood correctly, would I queue each of the Backbone.sync calls and then use setTimeout to send my queue to the server in a few seconds?
Also, if I rewrite Backbone.sync, I donβt need the save method somewhere for a collection that will parse the json response (the server response should send a list of objects) and then call model.set for each item in the collection? Does anyone have sample code?
Thank!
Nick Lang Nov 02 '11 at 2:52 2011-11-02 02:52
source share