Skip to content

@nowk /application.js
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Formtastic errors w/ ajax + knockout.js and responds_to :json
$.ajax({
error: function(jqXHR, textStatus, errorThrown) {
// reset
$('.formtastic li').removeClass("error");
$('.formtastic li .inline-errors').remove();
// set the errors
// TODO turn into dynamic
// TODO include errors for :base and #semantic_errors
var errors = ko.mapping.toJS(ko.mapping.fromJSON(jqXHR.responseText));
$.each(errors, function(key, value) {
$(".formtastic.menu li#menu_"+key+"_input.required").addClass("error");
$(".formtastic.menu li#menu_"+key+"_input.required").append('<p class="inline-errors">'+value.join(", ")+'</p>');
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.