Unsaved Changes Close Confirmation example
Unsaved Changes Close Confirmation example
jbblake
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?');
}
});
});
This discussion has been closed.
Replies
Do you mean this example? It appears to work okay on that page for me. What browser are you using?
Allan
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
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
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?