Reputation: 716
This is a little strange... I have a simple workaround for the javascript confirm alert for jQuery using jqueryui to check the content of an input. If the user clicks ok code execution should continue and if they click cancel it should stop. I'm not getting any errors when running the code so I'm guessing it's something simple that I'm missing.
var $confirmDialog = $('<div></div>')
.html('Click OK to confirm. Click Cancel to stop this action.')
.dialog({
autoOpen: false,
title: 'That\'s a lot of rows...',
width: 320,
position: [125, 50],
buttons: {
"OK": function () {
$(this).dialog("close");
return true;
},
"Cancel": function () {
$(this).dialog("close");
return false;
}
}
}).css("font-size", "12px");
if($('#numRows').val() > 10000)
{
return $confirmDialog.dialog('open');
}
alert('I got here YAY!');
The alert never triggers when the condition is met i.e. more than 10000 in the numRows input. The dialog is showing but clicking on OK or CANCEL seems to kill the jQuery code and it doesn't continue.
Upvotes: 1
Views: 43
Reputation: 689
You have a
return
which gets executed when the condition is true. For that reason, the code will not get to the alert statement in that case.
Upvotes: 3