I have a RESTful service that, when I try to save a new record does a unique email check. When it fails, I return a 400 error code along with a JSON message with an “errors” value in it.
Unfortunately, my error callback on my save doesn’t seem to be firing. Any suggestions?
var nRecord = new RecordModel(values);
nRecord.save({
wait: true,
error: function(model,response){
console.log('error2');
obj.errorHandler(model,response);
},
success: function() {
console.log('success2');
obj.alert('Information saved!','Record Created!','success');
// if there were no errors, clear the list
$('#record-form :input').val('');
}
});
“Error2” is never displayed in the console. Thoughts?
You seem to be passing your error handler and other options as model attributes and saved into the model instead. Trying passing null as a first parameter to the save function. Hopefully this will make it work 🙂