I use the following code to use the default javascript validation via jquery ui dialog.
jQuery.extend({
confirm: function(message, title, okAction) {
jQuery("<div></div>").dialog({
open: function(event, ui) { jQuery(".ui-dialog-titlebar-close").hide(); },
buttons: {
"Ok": function() {
jQuery(this).dialog("close");
return true;
},
"Cancel": function() {
jQuery(this).dialog("close");
return false;
}
},
close: function(event, ui) { jQuery(this).remove(); },
resizable: false,
title: title,
modal: true
}).text(message);
}
});
jQuery.confirm(
"LogOut",
"Do you want to log out",
function() {
});
Now I need to use the same code in the logout action. So I can replace javascript validation in code.
<a class="homeImage" onclick="return confirm('Do you want to logout?');" href="/future/myhome/head?$event=logout">LOG OUT</a>
The problem that I am facing now is that when I replace the confirmation with another function and wait for its return value to make a decision, the dialog box does not return the value of the variable. These two functions are performed simultaneously (showing a warning, but also fall into the href target). Is there a way that a method can return true or false value and therefore move on to the href target.
: jQuery Extend, jQuery UI
: js