I'm creating a confirm message box using this plugin.
<input type="button" id="deleteByID" value="Delete Item By ID" />
<div id="modal">
<div id="heading">
Are you sure you want to do that?
</div>
<div id="content">
<a href="#" id='revealYes' class="button green close"><img src="images/tick.png">OK</a>
<a href="#" id='revealNo' class="button red close"><img src="images/cross.png">Cancel</a>
</div>
</div>
$('#deleteByID').click(function(e) {
$('#modal').reveal({
animation: 'fade',
animationspeed: 320,
closeonbackgroundclick: true,
dismissmodalclass: 'close'
});
$('#revealYes,#revealNo').click(function(){
var choice = $(this).text();
if(choice == 'OK'){
deleteItemInCart(item5);
updateQtyLabel('qtyItem');
}else{
return false;
}
});
});
I want to change the blog
#modal
into dynamicdiv
as this function, how can I call this function in my page to create a#modal
div as html above.function messageBox(heading, confirmMsg, cancelMsg){ var box = ' <div id="modal"><div id="heading">'+heading+'</div><div id="content"> <a href="#" id="revealYes" class="button green close"><img src="images/tick.png">'+confirmMsg+'</a> <a href="#" id="revealNo" class="button red close"><img src="images/cross.png">'+cancelMsg+'</a>'; return box; }
- In my console,function
deleteItemInCart()
increase executing time + 1 every time I click onOK
button. I meant, when I click on theOK
button 1st time, the function called 1 time then the message box closed. Then click onOK
button 2nd time, the function is call 2 times in my console. Any idea what could be causing this
Any help would be much appreciated, thank you.