javascript - jQuery '.click(callback)' prevents the default event -


I'm trying to stop double-clicking on a form button , for which element Has been disabled for a few seconds.

  & lt; Form action = "#" method = "POST" & gt; & Lt; Input type = "text" / & gt; & Lt; Input type = "password" /> & Lt; Button class = "myButton" type = "submit" & gt; Send & lt; / Button & gt; & Lt; / Form & gt; Var = this; This.element = $ (". MyButton"); This.element.click (function (e) {this.element.prop ("disabled", true); window.setTimeout (function () {that.element.prop ("disabled", false);}, 2000); });  

It succeeds in enabling / deactivating, but the .click () function prevents the promotion of events (automatically? O_o), and Page < Note

is trying to add behavior to a form button that < Strong> was already working fully (posting the aciton link) as well as enable / disable work can be done entirely (even if the final errors I gave up A code was made in the optimization).

PS - Any solution should be cross-browser and should be compatible with IE8. By disabling the button

, you are blocking the operation of the post. Then disable the form you want to do and then use the JavaScript call to actually submit the form. It may look like this:

  $ ('. Mybutton'). Click (function () {$ button = $ (this); $ button.attr ('disabled', true); $ Button.closest ('form'). Submit (); setTimeout (function () {$ button. Attr ('disabled', false);}, 2000);});  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -