jqueryui tooltip全局绑定

时间:2013-02-26 07:28:05

标签: javascript jquery jquery-ui tooltip jquery-ui-tooltip

我在页面上有动态元素来去,隐藏和显示等。每次将元素附加到dom时,我都想设置一个全局处理程序(通过文档),而不是绑定tooltip()。 它工作,但我想要一个多个“项目”的全局处理程序,它不起作用,我找不到一个很好的例子。这就是我试过的:

$( document ).tooltip({ // works good if its the only one
    items: ":not(.btn-box-share)",
    ... // close, content, etc (methods)
});

$( document ).tooltip({ //! replaces the previous bind to document..
  items: '.btn-box-share',
  ... // different close, content, etc
});

2 个答案:

答案 0 :(得分:0)

       $( document ).tooltip({ //
            items: "://
            extraClass:"t3"
        });

使用额外的类选项并使用不同的样式定义区分它们,样式是否不同。实例应该继承自己的属性并为ya工作。我没有尝试过你的特殊情况,但它应该有用。

答案 1 :(得分:0)

我注意到项目选择器有一些奇怪的行为。我能够通过构建选择器对象然后将对象传递给items属性来解决它。可能值得一试。

您还可以使用hasClass或类似功能绕过项目并将逻辑构建到工具提示函数中。