Slide 30
Slide 30 text
commit: function (evt) {
evt.preventDefault();
var view = this;
this.clearErrors();
this.model.save({
name: this.$el.find("#name").val(),
description: this.$el.find("#description").val(),
contact_email: this.$el.find("#contact_email").val()
}, {
success: function (model, response, options) {
view.close();
},
error: function (model, xhr, options) {
var feedback = JSON.parse(xhr.responseText);
_.each(feedback.errors, function (errors, field) {
var errorField = view.$el.find('#'+field);
errorField.parents("div.control-group").addClass("error");
errorField.parents("div.controls").
append("" + errors.join("\n") + "");
});
}