I want to achieve.
1. Creating a single model on model.save should point to url
mentioned in Models attributes
2. I want to do a bulk save ( how can i do that ). So, as per example, say I have arrays of books model and I want to save it at once using Collection's url.
var BookModel = Backbone.Model.extend({
idAttribute: 'id',
url: function() {
return 'http:/test.com/books/addsinglebook'
},
defaults: {
id: null,
name: ''
},
});
var BookCollection = Backbone.Collection.extend({
url: 'http:/test.com/books/addbulkbooks',
model: BookModel,
});
// bookmodel.save() should point to /addsinglebook
// bookcollection.somesavemethod() should point to /addbulkbooks
Since Backbone collection doesn't have a save
and create
is for a single model, do I need to add my own method to the prototype for implementing a bulk save?