“How” to save an entire collection in Backbone.js - Backbone.sync or jQuery.ajax?

前端 未结 11 1303
醉梦人生
醉梦人生 2020-11-28 19:45

I am well aware it can be done and I\'ve looked at quite a few places (including: Best practice for saving an entire collection?). But I\'m still not clear \"exactly how\"

11条回答
  •  囚心锁ツ
    2020-11-28 20:41

    I ended up just having a 'save' like method and called $.ajax within it. It gave me more control over it without the need to add a wrapper class as @brandgonesurfing suggested (although I absolutely love the idea :) As mentioned since I already had the collection.toJSON() method overridden all I landed up doing was using it in the ajax call...

    Hope this helps someone who stumbles upon it...

提交回复
热议问题