【发布时间】:2011-03-11 15:03:49
【问题描述】:
我在触发器上创建了一个 jQuery 工具的叠加层:
$('button').overlay(
{
...
});
我以后如何禁用和重新启用覆盖?我希望我的$('button') 元素保留为链接,但我不想在点击时显示叠加层,而是要显示警报?
类似的东西:
if( needToDisableOverlay() )
{
$('button').overlay().disable(); // no such thing...
$('button').bind( 'click.alert', function()
{
alert( 'The overlay has been disabled' );
});
}
// later on
if( needToEnableOverlay() )
{
$('button').unbind( 'click.alert' );
$('button').overlay().enable(); // no such thing...
}
我知道我可以使用
$('button').unbind('click');
从按钮中删除 all 点击处理程序(包括 Overlay load() 函数),但我认为这不是一种干净的方式,尤其是如果我有其他想要维护的点击处理程序。
也许我可以在 Overlay 的 onBeforeLoad 处理程序中使用标志,如果设置了标志则返回 false ?
实现这一目标的正确方法是什么?
【问题讨论】:
标签: jquery overlay jquery-tools unbind