Using the code from the jqModal website, section FUN! Overrides:
http://dev.iceburg.net/jquery/jqModal/#examples
(I edited the code to make use of a callback function)
function confirm(msg,callback) {
$('#confirm')
.jqmShow()
.find('p.jqmConfirmMsg')
.html(msg)
.end()
.find(':submit:visible')
.click(function(){
if(this.value == 'yes')
(typeof callback == 'string') ?
window.location.href = callback :
callback();
$('#confirm').jqmHide();
});
}
$().ready(function() {
$('#confirm').jqm({overlay: 88, modal: true, trigger: false});
// trigger a confirm whenever links of class alert are pressed.
$('a.confirm').click(function() {
confirm('About to visit: '+this.href+' !',callbackfunction);
return false;
});
});
function callbackfunction()
{
console.log("callback triggered");
}
The problem: each time when the confirm function is called, the callback gets triggered incrementally, so when I click the 2nd time, the handler gets executed 2 times, the 3th time, 3 times and so on.