Tomas GF schrieb:
I'm using jQuery Validate (v. 1.2.1) on a page with several forms. I iterate
through the forms using each(). The validation is working but when I try to
append a loader (using ajaxStart()), it's appended to the wrong div (always
on the second form).
The code:
$(document).ready(function() {
var loader = jQuery('<div id="loader"><img
src="_js/loading.gif" alt="loader" width="20"
height="20"></div>');
$.validator.setDefaults({
debug: true,
focusInvalidElement: true,
submitHandler: function(form) {
$(form).ajaxForm();
var options = { target: $(form).parent(), clearForm: true, resetForm:
true }
$(form).ajaxSubmit(options);
}
});
$("form").each(function(i){
$(this).validate();
$(this).ajaxStart(function(){
$(this).parent().append(loader);
})
});
});
Another problem is that IE 6 sends the message twice...
Thanks for your help.
ajaxStart is a global event, so it gets triggered for each form you have.
Jörn