Consider:
var isSaveRequired = false;
function saveChanges() {
if(isSaveRequired ) {
if(confirm("<%=strings.getText("This is come from server side")%>")) {
isSaveRequired=false;
return true;
}
else {
return false;
}
}
return true;
}
Here I need to replace confirm with bootbox.confirm (in our project, the bootbox.js library is there already).
function saveChanges() {
if (isSaveRequired) {
bootbox.confirm('<%= strings.getText("this msg come from server side") %>', function(result) {
if (result) {
isSaveRequired = false;
return true;
}
});
return false;
}
return true;
}
But here the problem is the pop up (unsaved data will be lost) showing correct as only, but if I click OK then it's not redirecting to another page based user choice.
But here the problem is the pop up (unsaved data will be lost) showing correct as only, but if I click OK then it needs to be navigating to another page based user choice.
We note this in the docs in quite a few places: Bootstrap modals (and therefore Bootbox modals) are asynchronous:
So in this case:
saveChanges()will complete while the dialog is still active. So, if you want something like a redirect to happen only if the user confirms something, you'd probably want something like:Disclosure: I am one of the devs for the Bootbox project