'Bootbox does the same for "ok" and "cancel" callback. It does the same for prompt as well
Bootbox closes and stays on the same page. It should redirect to a different page onClick and "ok" after that. It is an MVC application and redirects to Index action upon Click. The same code works for traditional Jquery confirm box.
$('.navbar, .navv').click(function(e) {
e.preventDefault();
if(bootbox.confirm("Are you sure you want to leave the page!",
function (result) {
if (result === true) {
return true; //should redirect to the Home page
} else {
return false; //Should stay in the same page
}
}));
});
Solution 1:[1]
Just remove the if
loop around bootbox.confirm
and return only if it is true
.
$('.navv').click(function(e) {
e.preventDefault();
bootbox.confirm("Are you sure you want to leave the page!",
function (result) {
if(result) {
window.open($('.navv').attr('href'));
};
});
});
Click on this link to see demo. https://jsfiddle.net/y3o8gamp/
Solution 2:[2]
please check result value, if was null == cancel button cliked if was empty string '' ok button with empty comment box clicked.
this worked for me.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Soham |
Solution 2 | Omid Marofpor |