I have a backbone/backgrid editable grid, and everytime I edit a cell the "change" event is fired up twice and I end up making two separate PUT requests.
I know that this happens because the "change" event fires once when I edit it in the cell, and another when the data comes back from the server; and that the behaviour could be avoided by passing {wait: true}
to the save
method, but I don't know where I need to overload it.
My model declaration is like this:
var Redirects = Backbone.Model.extend({
urlRoot: '/global/redirects',
initialize: function () {
Backbone.Model.prototype.initialize.apply(this, arguments);
this.on("change", function (model, options) {
if (options && options.save === false) return;
model.save({
error: alertMe
});
});
this.on('fetch request', function (e) {
loadingOn(e);
});
this.on('sync error', function (e) {
loadingOff(e);
});
this.on('error', function(e, resp){
alertMe(e, resp);
});
}
});