Reputation: 5533
Ive tried a lot of things for this, but can't seem to get it to work as desired. It either displays the confirm dialog all the time or not at all. I have 10 checkboxes with the class of "ex" if none of them are checked when you click the "next" button ("#step0Next") I want it to display a confirm dialog.
$("#step0Next").live('click', function(event) {
$('#step1Prev').click(); //go back to step 1
if($('.ex').is(":not(:checked)")) { //my conditions for popping confirm dialog
if(!confirm("You have not selected an exchange(s). If you continue, all streaming market data will be delayed by ten minutes excluding market metrics which will be real time. Press'OK' to continue or 'Cancel' to add an exchange(s).")) return; //user clicks OK
$('#step0Next').die('click');
}
$(this).triggerHandler('click'); //make #step0Next behave as usual after clicking OK
});
Upvotes: 2
Views: 1251
Reputation: 10572
Your function in general just seems a bit complicated. One place you can simplify it is on your check for "checked":
if($(".ex:checked").length == 0){ /* do confirm here*/}
Upvotes: 1