solution for dynamically loaded, multiple ajax forms with jquery validate:

function setupForm(form, target){
        $("input.ajax-invisible").hide();
        $(form).validate({ // ataches the validator
                currentForm : $(form),
                submitHandler: function() { submit(form, target) }
        });
}

function submit(form, target){
        if ($(target) != null) {
                $(form).ajaxSubmit({target: $(target)});
        } else {
                form.submit();
        }
}

On Fri, Apr 18, 2008 at 6:19 PM, Jan Limpens <[EMAIL PROTECTED]> wrote:
> In the meantime I refactored this to:
>
>  function setupForm(form, target){
>
>         $("input.ajax-invisible").hide();
>         $(form).validate({
>                 currentForm : $(form)
>         });
>         if ($(target) != null) {
>                 $(form).ajaxForm({
>                         beforeSubmit: function(){$(form).valid()},
>                         target: $(target)
>                 });
>         }
>  }
>
>  but the problem persists... any help?
>
>
>
>  On Fri, Apr 18, 2008 at 1:06 PM, Jan Limpens <[EMAIL PROTECTED]> wrote:
>  >
>  >  In a wizard I have a container page with a few divs, every div can
>  >  host a certain form, that post it's result to another div. Everything
>  >  via ajax.
>  >  On the bottom of these forms, I call something like this:
>  >  jQuery(function($){
>  >         setupAddressForm();
>  >  });
>  >
>  >  which looks like this
>  >  function setupAddressForm(){
>  >         var form = setupForm($("#formAddressStep"));
>  >         createAjaxContext(form, $("#panelpaymentoption"));
>  >  }
>  >
>  >  function setupForm(form){
>  >         $("input.ajax-invisible").hide();
>  >         $(form).validate({
>  >                 submitHandler: function(form) {
>  >                         $(form).ajaxSubmit();
>  >                 },
>  >                 currentForm : form
>  >         });
>  >         return form;
>  >  }
>  >
>  >  function createAjaxContext(form, nextStep, onSuccess){
>  >         form.ajaxForm({
>  >                 target: nextStep,
>  >                 success: onSuccess
>  >                 });
>  >  }
>  >
>  >  But only the very first form is actually validated, Firebug tells me
>  >  that it always remains the currentForm.
>  >
>  >  How can I set subsequent forms to be the currentForm?
>  >
>
>
>
>  --
>  Jan
>  ___________________
>  [EMAIL PROTECTED]
>  www.limpens.com
>  +55 (11) 3082-1087
>  +55 (11) 3097-8339
>



-- 
Jan
___________________
[EMAIL PROTECTED]
www.limpens.com
+55 (11) 3082-1087
+55 (11) 3097-8339

Reply via email to