How to reenable event.preventDefault?

javascript, jquery

Solution

You would have to unbind the event and either rebind to a separate event that does not preventDefault or just call the default event yourself later in the method after unbinding. There is no magical event.cancelled=false;

As requested

 $('form').submit( function(ev){

         ev.preventDefault();

         //later you decide you want to submit
         $(this).unbind('submit').submit()

  });

Problem

I have a web page which I have prevented the default action on all submit buttons, however I would like to re-enable default submit action on a button how can I do this? I am currently preventing the default action using the following: ``` $("form").bind("submit", function(e){ e.preventDefault(); }); ``` I have successfully done this using the following: ``` $(document).ready(function(){ $("form:not('#press')").bind("submit", function(e){ e.preventDefault(); }); ``` But can I do this dynamically when the button is clicked?

Original source

Related problems