检查是否jQuery“Fancybox”已经注册了? [英] Check if jQuery "Fancybox" is already registered?
本文介绍了检查是否jQuery“Fancybox”已经注册了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$(document).ready(function(){
$(#help)。fancybox({
'width':'90%',
'height':'90%',
'autoScale' :true,
'transitionIn':'elastic',
'transitionOut':'none',
'titleShow':false,
'type':'iframe'
});
});
然而,在页面传输/回发上,它正在注册多次,这将减慢到这一点的打破。有没有办法检查事件是否已经注册,如果没有,请注册?
伪代码:
($(help)。fancybox == null))
{
/ /注册花式框
}
解决方案
当fancybox运行,它在jQuery的数据
对象中添加了一个 fancybox
条目。
您可以测试其存在:
if(!$(#help)。data )
{
//注册花式框
}
I'm regestering a jQuery fancybox like so:
$(document).ready(function() {
$("#help").fancybox({
'width': '90%',
'height': '90%',
'autoScale': true,
'transitionIn': 'elastic',
'transitionOut': 'none',
'titleShow': false,
'type': 'iframe'
});
});
However, on page transfer/postback it is getting registered multiple times, which slows it down to the point of breaking. Is there a way to check if the event is already registered, and if not, register it?
Pseudo code:
//check if fancybox has not been registered
if($("help").fancybox == null))
{
//register fancy box
}
解决方案
When fancybox runs, it adds a fancybox
entry into jQuery's data
object.
You can test for its presence:
if( ! $("#help").data().fancybox )
{
//register fancy box
}
这篇关于检查是否jQuery“Fancybox”已经注册了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文