Unsaved Changes Close Confirmation example

Unsaved Changes Close Confirmation example

jbblakejbblake Posts: 14Questions: 6Answers: 0

The example did not work for me. Best of my knowledge there is no submit event.
Also the preClose event needs to be set on after a submit or the confirm box is not show. My code is below

    var openVals;
    localEditor
    .on('open', function (e, mode, action) {
        openVals = JSON.stringify(localEditor.get());
        })
    .on('preClose.confirm', function (e) {
        // On close, check if the values have changed and ask for closing confirmation if they have
        //console.log(openVals);
        if (openVals !== JSON.stringify(localEditor.get())) {
            return confirm('You have unsaved changes. Are you sure you want to exit?');
        }
    })
   
   .on('postEdit.confirm', function (e, json, data) {
       localEditor.off('preClose.confirm');
   })
   .on('submitComplete', function (e, jason, data, action) { 
       //Turn the event back on
       localEditor.on('preClose.confirm', function (e) {
           if (openVals !== JSON.stringify(localEditor.get())) {
               return confirm('You have unsaved changes. Are you sure you want to exit?');
           } 
       });
   });

Replies

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Do you mean this example? It appears to work okay on that page for me. What browser are you using?

    Allan

  • jbblakejbblake Posts: 14Questions: 6Answers: 0

    yes that is the example. I am using IE 11. I am new using editor, so I may be doing something bad. Not a big deal, thank you for your reply

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    I've just tried the example page on IE11 and it appears to work okay for me.

    I load the page, select a row, edit an item and then attempt to click out of the modal and it shows an alert message. Is that message not showing for you on that page?

    Allan

  • wblakencwblakenc Posts: 78Questions: 17Answers: 1

    Allan,
    I too am having trouble with this one. If I click out of the modal, it works nicely. However, if I click submit I get the warning message. Is there a way to test for which event triggered the preClose event?

This discussion has been closed.