Try overriding the .sync () method. Backbone.save () delegates to Backbone.sync () after overriding the success callback you are passing to. This is where the model update comes from.
From the source of the Backbone.save () method:
var success = options.success; options.success = function(resp) { // Ensure attributes are restored during synchronous saves. model.attributes = attributes; var serverAttrs = model.parse(resp, options); if (options.wait) serverAttrs = _.extend(attrs || {}, serverAttrs); if (_.isObject(serverAttrs) && !model.set(serverAttrs, options)) { return false; } if (success) success(model, resp, options); model.trigger('sync', model, resp, options); }; wrapError(this, options); method = this.isNew() ? 'create' : (options.patch ? 'patch' : 'update'); if (method === 'patch') options.attrs = attrs; xhr = this.sync(method, this, options);
You can pass a custom option when you call ".save ()", then find that option and override the .success callback option to ".sync ()". Something like this, maybe?
MyModel = Backbone.Model.extend({ sync: function (method, context, options) { if (options.skipUpdateOnResponse) { options.success = myCusomSuccessFunction; } } }); myModel = new MyModel(); myModel.save({...}, {skipUpdateOnResponse: true})
source share