n0minal
n0minal

Reputation: 3223

Backbone model success and error options

Adding success and error callback in backbone model#save doesn't work.

I upgraded to 0.9.10 which is the newest one and to my surprise

model.save{ 
  success : function(model, response, options){

  },

  error : function(model, response, options){

  });

doesn't work. Any ideas?

Upvotes: 0

Views: 243

Answers (1)

jevakallio
jevakallio

Reputation: 35920

The options object should be passed as the second argument. The first arguments is reserved for attributes you want to set in the save operation:

model.save({attr:'val'}, {
  success: function() { },
  error: function() { }
});

If you don't want to pass any new values to save, you can pass either and empty object ({}) or null.

Upvotes: 1

Related Questions