javascript - Backbone: Batch save models in single request? -


I have a page using the spinal cord to manage a collection of models.

Sometimes this collection gets bigger and if the user performs actions that make many changes from them, it can be a result. In some cases, hundreds of AJAX requests cause simultaneous firing.

Does the spinal cord have somehow requested a batch operation in some way?

There is no built-in method for backbone batch operation. There is a common pattern for using compilation, a backbone. Wrap the collection in the model and simply overwrite the tojson method. Then you can treat it like any other backbone. Call the model and simply save () .

  var Post = Backbone.Model.extend ({...}); Var Post = Backbone compilation. Extension ({Model: Post, ...}); Var Post List = Backbone.Model Examiner ({url: '/ path / for / bulk / operations', toJSON: function () {// is a collection of models in this situation. This.model.toJSON ();}});  

Another option is to add a save () method to your collection and backbone. Sync is

  var post = backbone.collection.andend ({... save: function (options) {return backbone.Sink ('create', this, options);} });  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -