Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Formtastic errors w/ ajax + knockout.js and responds_to :json
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) {
$(" li#menu_"+key+"_input.required").addClass("error");
$(" 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.