Little help with a loop
Little help with a loop
I am trying to loop thru a json array of errors specific to a form #id (sel) but it is not working.
function setErrors(errors, sel){
errorUpdate(sel);
//alert(sel); // returns #add_form
$(sel).each(errors, function(field, msg) {
//alert(sel); returns nothing
var parent = $('[data-field='+ field +']').parent();
$('[data-field='+ field +']').addClass('form-error', function(){
$(parent).append( '<span class="help-inline error-message">' + msg + '</span>' );
});
});
}
Any insight would be great.
Thanks,
Dave