Skip to content

Instantly share code, notes, and snippets.

@eastridge
Last active December 15, 2015 10:59
Show Gist options
  • Save eastridge/5249448 to your computer and use it in GitHub Desktop.
Save eastridge/5249448 to your computer and use it in GitHub Desktop.
Application.View.extend({
name: "some-view",
events: {
"submit form": function(event) {
event.stopPropagation();
$('error-messages-selector').empty();
this.serialize(function(attr) {
});
},
error: function(errors) {
_.each(errors, function(e) {
$('label[for="' + e.name + '"]).addClass('error');
$('error-messages-selector').append('<p>' + e.message + '</p>');
});
}
},
validateInput: function(attrs) {
var errors = [];
if (attrs.title === '') {
errors.push({
name: 'title',
message: 'cant be blank'
});
}
return errors;
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment