Skip to content

Instantly share code, notes, and snippets.

@jordanisip
Created November 21, 2008 20:17
Show Gist options
  • Save jordanisip/27607 to your computer and use it in GitHub Desktop.
Save jordanisip/27607 to your computer and use it in GitHub Desktop.
(function($){
$.fixieAjaxForm = function(onSuccess) {
// $('form').fixieAjaxForm()
// $(this) == $('form') inside this function
$(this).ajaxForm(function(str) {
var data = $.parseJSON(str);
$(this).find('label.error').removeClass('error');
if (data.errors.length === 0) {
$(this).resetForm();
onSuccess(data);
} else {
$.each(data.errors, function(){
$('label[for='+ this[0]+']').addClass('error');
});
}
})
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment