I am using wtforms and here is my submit button:
{{ form.submit(class="btn btn-outline-info") }}
And This is my onbeforeunload function:
<script type="text/javascript">
  window.onbeforeunload = function() {
  return "Are you sure you want to navigate away?";
  }
</script>
I know in normal html forms I can probably use jquery to do this:
reference:
jquery-function-before-form-submission stackoverflow discussion
clear onbeforunload stackoverflow discussion
<head>
  <script src="jquery-3.5.1.min.js"></script>
</head>
<script>
$('#myform').submit(function(event) {
 event.preventDefault(); //this will prevent the default submit
  window.onbeforeunload = null;
  
 $(this).unbind('submit').submit(); // continue the submit unbind preventDefault
})
<script>
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....)
Thanks in advance!
 
     
    