[jQuery] Re: jQuery + Validation: submit() is sending multiple form submits

2009-02-08 Thread James

Every time you're doing:

you're re-attaching an additional submit event to the form, so it's
executing it multiple times every time you submit.
What is it you're trying to do? When you define submitHandler for
validate, you should be doing whatever you're doing in $(form).submit
() inside the submitHandler.

On Feb 8, 7:21 am, zubin zubin...@yahoo.com wrote:
 I'm having a problem with validating first then submitting a form with
 jQuery after success. It works however it seems like my submit()
 function keeps sending multiple submits and keeps growing each time i
 reuse the form (i made sure the values are reset after each submit).
 I'm not sure if its my code since i've re-checked it for hours to no
 avail. Here is the code in a nut-shell:

 My form with id of #form-external-link is validated when submit button
 is clicked:

 $(#form-external-link).validate({
         rules: {
                 exlink_url: {
                         required: true,
                         url: true
                 }
         },
         submitHandler: function(form) {
                 alert('This will pop up only once as it should');
                 $(form).submit(function() {
                         alert('This will pop up every twice, 3x, 4x, etc. 
 after each
 validate success');
                 });
         }

 });

 Am I missing something from my code??


[jQuery] Re: jQuery + Validation: submit() is sending multiple form submits

2009-02-08 Thread James

Hmm.. code didn't display properly.

I wanted to say, every time you're doing
$(form).submit(...)

you're re-attaching an additional submit...

On Feb 8, 9:13 am, James james.gp@gmail.com wrote:
 Every time you're doing:

 you're re-attaching an additional submit event to the form, so it's
 executing it multiple times every time you submit.
 What is it you're trying to do? When you define submitHandler for
 validate, you should be doing whatever you're doing in $(form).submit
 () inside the submitHandler.

 On Feb 8, 7:21 am, zubin zubin...@yahoo.com wrote:

  I'm having a problem with validating first then submitting a form with
  jQuery after success. It works however it seems like my submit()
  function keeps sending multiple submits and keeps growing each time i
  reuse the form (i made sure the values are reset after each submit).
  I'm not sure if its my code since i've re-checked it for hours to no
  avail. Here is the code in a nut-shell:

  My form with id of #form-external-link is validated when submit button
  is clicked:

  $(#form-external-link).validate({
          rules: {
                  exlink_url: {
                          required: true,
                          url: true
                  }
          },
          submitHandler: function(form) {
                  alert('This will pop up only once as it should');
                  $(form).submit(function() {
                          alert('This will pop up every twice, 3x, 4x, etc. 
  after each
  validate success');
                  });
          }

  });

  Am I missing something from my code??


[jQuery] Re: jQuery + Validation: submit() is sending multiple form submits

2009-02-08 Thread zubin

Hi James! Thanks for the quick reply. I'm still confused as to where I
should place my $(form).submit(..). so i'm not re-attaching additional
submit events?

What i'm doing basically is: 1. have Validate pass the form 2. submit
the form via ajax
The only thing is that the form is always being reused to submit data
which causes the symptoms you've identifed...



On Feb 9, 3:14 am, James james.gp@gmail.com wrote:
 Hmm.. code didn't display properly.

 I wanted to say, every time you're doing
 $(form).submit(...)

 you're re-attaching an additional submit...

 On Feb 8, 9:13 am, James james.gp@gmail.com wrote:



  Every time you're doing:

  you're re-attaching an additional submit event to the form, so it's
  executing it multiple times every time you submit.
  What is it you're trying to do? When you define submitHandler for
  validate, you should be doing whatever you're doing in $(form).submit
  () inside the submitHandler.

  On Feb 8, 7:21 am, zubin zubin...@yahoo.com wrote:

   I'm having a problem with validating first then submitting a form with
   jQuery after success. It works however it seems like my submit()
   function keeps sending multiple submits and keeps growing each time i
   reuse the form (i made sure the values are reset after each submit).
   I'm not sure if its my code since i've re-checked it for hours to no
   avail. Here is the code in a nut-shell:

   My form with id of #form-external-link is validated when submit button
   is clicked:

   $(#form-external-link).validate({
           rules: {
                   exlink_url: {
                           required: true,
                           url: true
                   }
           },
           submitHandler: function(form) {
                   alert('This will pop up only once as it should');
                   $(form).submit(function() {
                           alert('This will pop up every twice, 3x, 4x, etc. 
   after each
   validate success');
                   });
           }

   });

   Am I missing something from my code??- Hide quoted text -

 - Show quoted text -


[jQuery] Re: jQuery + Validation: submit() is sending multiple form submits

2009-02-08 Thread Jörn Zaefferer

Try this:

$(#form-external-link).validate({
   rules: {
   exlink_url: {
   required: true,
   url: true
   }
   },
   submitHandler: function(form) {
   alert('This will pop up only once as it should');
   form.submit();
   }
});

It triggers the native submit event just once, without binding an
additional submit event or, even worse, triggering the validation to
run again.

Jörn

On Sun, Feb 8, 2009 at 6:21 PM, zubin zubin...@yahoo.com wrote:

 I'm having a problem with validating first then submitting a form with
 jQuery after success. It works however it seems like my submit()
 function keeps sending multiple submits and keeps growing each time i
 reuse the form (i made sure the values are reset after each submit).
 I'm not sure if its my code since i've re-checked it for hours to no
 avail. Here is the code in a nut-shell:

 My form with id of #form-external-link is validated when submit button
 is clicked:

 $(#form-external-link).validate({
rules: {
exlink_url: {
required: true,
url: true
}
},
submitHandler: function(form) {
alert('This will pop up only once as it should');
$(form).submit(function() {
alert('This will pop up every twice, 3x, 4x, etc. 
 after each
 validate success');
});
}
 });

 Am I missing something from my code??



[jQuery] Re: jQuery + Validation: submit() is sending multiple form submits

2009-02-08 Thread James

Since you wanted do submit by Ajax;

$(#form-external-link).validate({
   rules: {
   exlink_url: {
   required: true,
   url: true
   }
   },
   submitHandler: function(form) {
   $.ajax(...);
   }

});

On Feb 8, 9:50 am, zubin zubin...@yahoo.com wrote:
 Hi James! Thanks for the quick reply. I'm still confused as to where I
 should place my $(form).submit(..). so i'm not re-attaching additional
 submit events?

 What i'm doing basically is: 1. have Validate pass the form 2. submit
 the form via ajax
 The only thing is that the form is always being reused to submit data
 which causes the symptoms you've identifed...

 On Feb 9, 3:14 am, James james.gp@gmail.com wrote:

  Hmm.. code didn't display properly.

  I wanted to say, every time you're doing
  $(form).submit(...)

  you're re-attaching an additional submit...

  On Feb 8, 9:13 am, James james.gp@gmail.com wrote:

   Every time you're doing:

   you're re-attaching an additional submit event to the form, so it's
   executing it multiple times every time you submit.
   What is it you're trying to do? When you define submitHandler for
   validate, you should be doing whatever you're doing in $(form).submit
   () inside the submitHandler.

   On Feb 8, 7:21 am, zubin zubin...@yahoo.com wrote:

I'm having a problem with validating first then submitting a form with
jQuery after success. It works however it seems like my submit()
function keeps sending multiple submits and keeps growing each time i
reuse the form (i made sure the values are reset after each submit).
I'm not sure if its my code since i've re-checked it for hours to no
avail. Here is the code in a nut-shell:

My form with id of #form-external-link is validated when submit button
is clicked:

$(#form-external-link).validate({
        rules: {
                exlink_url: {
                        required: true,
                        url: true
                }
        },
        submitHandler: function(form) {
                alert('This will pop up only once as it should');
                $(form).submit(function() {
                        alert('This will pop up every twice, 3x, 4x, 
etc. after each
validate success');
                });
        }

});

Am I missing something from my code??- Hide quoted text -

  - Show quoted text -


[jQuery] Re: jQuery + Validation: submit() is sending multiple form submits

2009-02-08 Thread zubin

Hey Jörn thanks for the reply, good to know! I went with James
solution which is perfect for what i'm working with. Thanks again
guys.

On Feb 9, 9:07 am, James james.gp@gmail.com wrote:
 Since you wanted do submit by Ajax;

 $(#form-external-link).validate({
        rules: {
                exlink_url: {
                        required: true,
                        url: true
                }
        },
        submitHandler: function(form) {
                $.ajax(...);
        }

 });

 On Feb 8, 9:50 am, zubin zubin...@yahoo.com wrote:



  Hi James! Thanks for the quick reply. I'm still confused as to where I
  should place my $(form).submit(..). so i'm not re-attaching additional
  submit events?

  What i'm doing basically is: 1. have Validate pass the form 2. submit
  the form via ajax
  The only thing is that the form is always being reused to submit data
  which causes the symptoms you've identifed...

  On Feb 9, 3:14 am, James james.gp@gmail.com wrote:

   Hmm.. code didn't display properly.

   I wanted to say, every time you're doing
   $(form).submit(...)

   you're re-attaching an additional submit...

   On Feb 8, 9:13 am, James james.gp@gmail.com wrote:

Every time you're doing:

you're re-attaching an additional submit event to the form, so it's
executing it multiple times every time you submit.
What is it you're trying to do? When you define submitHandler for
validate, you should be doing whatever you're doing in $(form).submit
() inside the submitHandler.

On Feb 8, 7:21 am, zubin zubin...@yahoo.com wrote:

 I'm having a problem with validating first then submitting a form with
 jQuery after success. It works however it seems like my submit()
 function keeps sending multiple submits and keeps growing each time i
 reuse the form (i made sure the values are reset after each submit).
 I'm not sure if its my code since i've re-checked it for hours to no
 avail. Here is the code in a nut-shell:

 My form with id of #form-external-link is validated when submit button
 is clicked:

 $(#form-external-link).validate({
         rules: {
                 exlink_url: {
                         required: true,
                         url: true
                 }
         },
         submitHandler: function(form) {
                 alert('This will pop up only once as it should');
                 $(form).submit(function() {
                         alert('This will pop up every twice, 3x, 4x, 
 etc. after each
 validate success');
                 });
         }

 });

 Am I missing something from my code??- Hide quoted text -

   - Show quoted text -- Hide quoted text -

 - Show quoted text -