1

I'm tyring to catch the page leave event & check if the user have any unsaved changes. When I'm trying with alert, its working fine, the page reloading/leaving after I press the ok button on alert box as expected. But I'm trying to use kendo window for the confirmation with yes, no & cancel button. The problem is kendo window can't prevent the page from leaving or reloading, it just pops up & the page leaves almost immediately, leaving the user no time to respond to the window. I would like to stop the page from leaving until I press a button on kendo window.

Here is my code:

window.onbeforeunload = function (e) {

            if (changeStatus == 1)
            {
              //e.preventDefault();
              saveChangeWindow.open();
              //alert("test");
            }
        }; 

if I place the e.preventDefault(), then the page is waiting but an default message showing, which I don't actually need. Please help.

Badhon Jain
  • 938
  • 6
  • 20
  • 38

1 Answers1

2

The short answer is you cant - showing a Window and waiting for the user to select a button is an async operation in contrast to the confirm or alert functions of the window.

Petur Subev
  • 19,983
  • 3
  • 52
  • 68