Ask Confirm when change page

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
Fakiro82
User
Posts: 108

Ask Confirm when change page

Post by Fakiro82 »

Hi,
When change page without save information I received an alert.
I would like to exclude the alert on the save button (submit) but I can not and exclude it.

My code on startup_script is:

var warnMessage = "Si consiglia di salvare le modifiche prima di lasciare la pagina altrimenti andranno perse!";

	$("select").change(function () {
		window.onbeforeunload = function () {
			return 'Attenzione.Le modifiche non salvate andranno perse!';
		}
	});
	$("input").change(function () {
		window.onbeforeunload = function () {
			return 'Attenzione.Le modifiche non salvate andranno perse!';
		}
	});
	$("textarea").change(function () {
		window.onbeforeunload = function () {
			return 'Attenzione.Le modifiche non salvate andranno perse!';
		}
	});
	$(function () {
		$('button[type=submit]').click(function (e) {
			window.onbeforeunload = null;	
		});
	});

function beforeUnload(evt) {
for (var name in CKEDITOR.instances) {
if (CKEDITOR.instances[name].checkDirty())
return evt.returnValue = "Attenzione.Le modifiche non salvate andranno perse!";
}
}

if (window.addEventListener)
window.addEventListener('beforeunload', beforeUnload, false);
else
window.attachEvent('onbeforeunload', beforeUnload);

Thank you,
Andrea


arbei
User
Posts: 9356

Post by arbei »

You need to determine when and where to trigger the event "onbeforeunload" and "beforeunload";


Fakiro82
User
Posts: 108

Post by Fakiro82 »

Hi arbei,
i need to deactivate trigger event on submit button (button save) in form.
How can i modify my code?

Thank you so much,
Andrea.


Post Reply