I am using the dirty-forms / are-you-sure js on a test form that confirms if the user does want to navigate away from a page with unsaved changes.
This works as expected, but I am also using a "please wait" image that shows when the user makes a call to the server.
How do I only trigger the "please wait" image ONLY when the user clicks on the "Leave this Page" button on the are-you-sure message pop up box?
Currently I have the please wait image triggered to appear when the user clicks on the cancel button, b/c I cannot think where else to trigger it from.
Here is my < head > code:
<div id="loading-div-background">
<div id="loading-div" >
<img src="{{ STATIC_URL }}img/page-loader.gif" />
</div>
</div>
Here is my template code:
<a href="{% url certification_details %}" class="btn" onclick="showProgressAnimation();">Cancel</a>
Here is the js code that I have:
<script>
$('form').areYouSure( {'message':'You have unsaved changes.'} );
</script>
EDIT - added the hide image css as requested.
This is the CSS that hides the please wait icon when the page 1st loads:
#loading-div-background {
background-color: rgba(246,246,246,0.7);
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 9999;
}