Here is the answer, you have to enter the static id in
all the different controls that you wish to exclude from the message…
I changed the original script from another blog to use this static id
instead of the value. It works now
You have to go into the script and add a line for every
control that you wish to exclude from the warning message. Now you will get an error message every time you leave the
form after making changes except for when the excluded controls are pressed.
You can see the highlighted code below to see what I changed
from the original script.
Put the following code in the HTML header of the page.
---------
<script
type="text/javascript">
$(function(){
$('#wwvFlowForm').data('htmldb',{'dirty':false});
$(':input:not(:hidden,:submit,:password,:button)').live('change',function(){
$('#wwvFlowForm').data('htmldb',{'dirty':true})
});
$(window).bind('beforeunload',function(){
if($('#wwvFlowForm').data('htmldb').dirty){return "The changes you made to
the page were not saved."}
});
/* List all buttons and controls you want to exclude warning message */
$( "#Save").unbind('click').removeAttr('onclick').click(function(){
$('#wwvFlowForm').data('htmldb',{'dirty':false});
javascript:apex.submit('SAVE')
});
$( "#Submit").unbind('click').removeAttr('onclick').click(function(){
$('#wwvFlowForm').data('htmldb',{'dirty':false});
javascript:apex.submit('SUBMIT')
});
If you have problems with the buttons not being disabled, you probably have a dynamic action in javascript. These two javasripts can conflict with eachother.Remove the script for the buttons that are not working and add this line to the javascript that is triggered when to the dynamic action for when button is pressed
This should fix your problem.
$('#wwvFlowForm').data('htmldb',{'dirty':false});
I have pasted your code in page header also excluded the buttons which are not want to show this message... Why its not working for pagination button (Previous / Next)
ReplyDeleteRemove the script for the buttons that are not working and add this line to the javascript that is triggered when the button is pressed
ReplyDeleteThis should fix your problem.
$('#wwvFlowForm').data('htmldb',{'dirty':false});
So for the Save button, you remove the code that unbinds and submits the button
ReplyDeleteREMOVE
$( "#Save").unbind('click').removeAttr('onclick').click(function(){
$('#wwvFlowForm').data('htmldb',{'dirty':false});
javascript:apex.submit('SAVE')
});
and add this to your Javascript Dynamic Action.:
$('#wwvFlowForm').data('htmldb',{'dirty':false});
I have pasted this code in the page header, but it seems to be prompting the message even for Save button.
ReplyDeleteMake sure the id for your save button = "SAVE"
DeleteThanks! I managed to get that working.
DeleteI have actually got another report on the same page as this form, and the report results are dynamic with selection from the drop down.
how do we exempt this from running for change in the results of this report?