如何 return 在 fancybox 中点击关闭按钮时确认?
How to return confirm on close button click in fancybox?
我想在我正在编辑的 fancybox 中单击按钮时提醒确认消息
closeBtn : '<a title="Close" class="fancybox-item fancybox-close" href="javascript:;"></a>',
这部分代码在fancybox.js中喜欢
closeBtn : '<a title="Close" class="fancybox-item fancybox-close" href="javascript:;" onClick="return confirm(\'Are you sure?\')"></a>',
这显示了确认对话框,但在 yes/no 上都显示 returns true.Fancybox 正在关闭。
试试这样的东西..
closeBtn : '<a title="Close" class="fancybox-item fancybox-close" href="javascript:;" onClick="return makesure();"></a>',
给函数外
function makesure(){return confirm('Are you sure?');}
我自己做的
我更改了 fancybox.js
中的一些代码
if (current.closeBtn) {
$(current.tpl.closeBtn).appendTo(F.skin).bind('click.fb', function(e) {
e.preventDefault();
F.close();
});
}
至
if (current.closeBtn) {
$(current.tpl.closeBtn).appendTo(F.skin).bind('click.fb', function(e) {
e.preventDefault();
if(confirm('Are you sure?')){
F.close();
}
});
}
您可以简单地使用:beforeClosing 方法来完成:
$(".fancyTrigger").fancybox(
{
'beforeClose' : function() {
return window.confirm('Close?');
}
});
看看这个 fiddle:
http://jsfiddle.net/5EV8r/826/
更多信息:
查看我们的 http://fancyapps.com/fancybox/ 文档部分。
我想在我正在编辑的 fancybox 中单击按钮时提醒确认消息
closeBtn : '<a title="Close" class="fancybox-item fancybox-close" href="javascript:;"></a>',
这部分代码在fancybox.js中喜欢
closeBtn : '<a title="Close" class="fancybox-item fancybox-close" href="javascript:;" onClick="return confirm(\'Are you sure?\')"></a>',
这显示了确认对话框,但在 yes/no 上都显示 returns true.Fancybox 正在关闭。
试试这样的东西..
closeBtn : '<a title="Close" class="fancybox-item fancybox-close" href="javascript:;" onClick="return makesure();"></a>',
给函数外
function makesure(){return confirm('Are you sure?');}
我自己做的 我更改了 fancybox.js
中的一些代码if (current.closeBtn) {
$(current.tpl.closeBtn).appendTo(F.skin).bind('click.fb', function(e) {
e.preventDefault();
F.close();
});
}
至
if (current.closeBtn) {
$(current.tpl.closeBtn).appendTo(F.skin).bind('click.fb', function(e) {
e.preventDefault();
if(confirm('Are you sure?')){
F.close();
}
});
}
您可以简单地使用:beforeClosing 方法来完成:
$(".fancyTrigger").fancybox(
{
'beforeClose' : function() {
return window.confirm('Close?');
}
});
看看这个 fiddle:
http://jsfiddle.net/5EV8r/826/
更多信息:
查看我们的 http://fancyapps.com/fancybox/ 文档部分。