Skip to content

Instantly share code, notes, and snippets.

@meehow
Created June 15, 2011 11:55
Show Gist options
  • Save meehow/1026934 to your computer and use it in GitHub Desktop.
Save meehow/1026934 to your computer and use it in GitHub Desktop.
$.post($(this).attr('action'), form.serialize(), function(answear){
form.find('.errorlist').remove();
$.each(answear['errors'], function(key, value){
var errors = '';
$.each(value, function(i,v){
errors += '<li>'+v+'</li>';
});
form.find('#id_'+key).before('<ul class="errorlist">'+errors+'</ul>');
});
if (answear['id']){
target = $(form.dialog('option', 'target'));
target.append('<option value="'+answear['id']+'">'+answear['value']+'</option>');
form.find('input').val('');
form.dialog('close');
}
}, 'json');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment