我正在尝试了解 cluetip 的实际工作原理。我有一个虚拟 DOM 结构,我对它做了一些警报,以检查在 anchor 元素上调用 cluttip('destroy') 后 cluetip 是否已被删除。但是,cluetip div 似乎仍然存在并且运行良好。这真的让我很困惑......
如果我错了请纠正我...据我所知,cluetip 在网页中有 1 个实例,它存在于标签层次结构中,即 clusetip > clusetip-outer > clusetip-inner。当它第一次附加到 html 元素(在我的例子中是一个 anchor )时,它会将自己附加到 DOM 结构的某处。
所以问题是:在 html 元素上调用 clusetip('destroy') 会实际删除 cluptip,还是会删除/重置 cluetip 中的某种变量(如果是,是哪个变量)?还是我完全偏离了轨道?
谢谢。
最佳答案
看起来所有 destroy 函数所做的就是删除事件触发器(第 28-30 行)
if (js == 'destroy') {
return this.unbind('.cluetip');
}
如果你想确保cluetip中的数据没有了,那就自己清除吧:
$('#cluetip-inner').empty();
更新:为了回答您关于查看某个元素是否绑定(bind)了任何内容的问题,我将向您推荐我从 James Padolsey's site 中找到的内容。 :
// List bound events:
console.dir( jQuery('#elem').data('events') );
// Log ALL handlers for ALL events:
jQuery.each($('#elem').data('events'), function(i, event){
jQuery.each(event, function(i, handler){
console.log( handler.toString() );
});
});
*注意:console
是指 Firebug 控制台。
关于javascript - jQuery cluttip ('destroy' ) 不会破坏/删除 cluetip?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1950197/