我不想执行ancy,没有确认,我会遇到困难,无法按需要工作。 以下实例是:Fancy Box v2。
The problem with the code below is that the function "do_something" is being call when HREF
"Test" is clicked and not being called when the user clicks #fancyConfirm_ok
.
function fancyConfirm(msg,callback) {
var ret;
jQuery.fancybox({
modal : true,
content : "<div style="margin:1px;width:240px;">"+msg+"<div style="text-align:right;margin-top:10px;"><input id="fancyconfirm_cancel" style="margin:3px;padding:0px;" type="button" value="Cancel"><input id="fancyConfirm_ok" style="margin:3px;padding:0px;" type="button" value="Ok"></div></div>",
afterShow : function() {
jQuery("#fancyconfirm_cancel").click(function() {
ret = false;
//jQuery.fancybox.close();
$.fancybox.close();
})
jQuery("#fancyConfirm_ok").click(function() {
ret = true;
jQuery.fancybox.close();
})
},
afterClose : function() {
if (typeof callback == function ){
callback.call(this, ret);
} else {
var callback_type = typeof callback;
alert(callback_type);
}
}
});
}
<a href="#" onclick="fancyConfirm( Are you sure you want to delete? , do_something( a , b ) );return false;">Test</a>