我试图实现花哨是没有确认,我有问题得到回调工作,如果需要。以下示例使用Fancybox v2。Fancybox的Javascript/jquery回调是否确认
下面的代码的问题是,当单击HREF
“测试”,并且当用户单击#fancyConfirm_ok
时未调用功能“do_something”正在调用。
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>
请您提供一个[的jsfiddle(http://www.jsfiddle.net)? – Neysor