I have a simple Backbone model:
define(function(require) {
var Backbone = require('backbone');
var SessionModel = Backbone.Model.extend({
url: 'http://stormy-ravine-2549.herokuapp.com/login',
parse: function(data) {
debugger;
}
});
return SessionModel;
});
Here is my code where I am saving the model:
var sessionModel = new SessionModel();
sessionModel.set('username', $('#email').val());
sessionModel.set('password', $('#password').val());
sessionModel.save({
success: function() {
debugger;
},
error: function() {
debugger;
}
});
I get a 200 response from the server with a json body of {"msg": "success"}. I hit the parse method in the model, but neither one of my callback functions get hit. Also, I am running my Chrome browser with CORS disabled. Doesn't either the success or errorcallback have to be hit?
You are telling backbone to only change the properties success and error. The second parameter is for options.
See Backbone model.save() not calling either error or success callbacks and also http://backbonejs.org/#Model-save
save accepts success and error callbacks in the options hash
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With