title: Is there a way to set window.onbeforeunload to null before an object is click?
body: <p>I am using wtforms and here is my submit button:</p>
  <pre><code>{{ form.submit(class=&quot;btn btn-outline-info&quot;) }}
  </code></pre>
  <p>And This is my onbeforeunload function:</p>
  <pre><code>&lt;script type=&quot;text/javascript&quot;&gt;
    window.onbeforeunload = function() {
    return &quot;Are you sure you want to navigate away?&quot;;
    }
  &lt;/script&gt;
  </code></pre>
  <p>I know in normal html forms I can probably use jquery to do this:</p>
  <p>reference:</p>
  <p><a href="https://stackoverflow.com/questions/21938788/jquery-function-before-form-submission/40330287">jquery-function-before-form-submission stackoverflow discussion</a></p>
  <p><a href="https://stackoverflow.com/questions/14093826/clear-onbeforeunload?">clear onbeforunload stackoverflow discussion</a></p>
  <pre><code>&lt;head&gt;
    &lt;script src=&quot;jquery-3.5.1.min.js&quot;&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;script&gt;
  $('#myform').submit(function(event) {
  
   event.preventDefault(); //this will prevent the default submit
  
    window.onbeforeunload = null;
    
   $(this).unbind('submit').submit(); // continue the submit unbind preventDefault
  })
  &lt;script&gt;
  </code></pre>
  <p>What should I do when I am working with these wtforms object? (p.s. I am not familiar with js or jquery....please point out what I done wrong if any....)</p>
  <p>Thanks in advance!</p>