function ValidateField(){
var bAllow= true;
//some checking here
if (bAllow == true && apl.val().trim() == \"\")
{
showDialog();
showDialog()
I have created this JSFIDDLE and changed the boolean parse because that was blowing up. Thanks, Pierre! This has saved me a lot of time.
javascript:
function confirmation(question) {
var defer = $.Deferred();
$('')
.html(question)
.dialog({
autoOpen: true,
modal: true,
title: 'Confirmation',
buttons: {
"Yes": function () {
defer.resolve("true");//this text 'true' can be anything. But for this usage, it should be true or false.
$(this).dialog("close");
},
"No": function () {
defer.resolve("false");//this text 'false' can be anything. But for this usage, it should be true or false.
$(this).dialog("close");
}
},
close: function () {
//$(this).remove();
$(this).dialog('destroy').remove()
}
});
return defer.promise();
};
function onclick(){
var question = "Do you want to start a war?";
confirmation(question).then(function (answer) {
console.log(answer);
var ansbool = (String(answer) == "true");
if(ansbool){
alert("this is obviously " + ansbool);//TRUE
} else {
alert("and then there is " + ansbool);//FALSE
}
});
}
$("#item").on('click', onclick);
HTML: