开发者

YUI tooltip widget pass class name instead of id?

How can I pass a class name to the YUI2tooltip: http://developer.yahoo.com/yui/examples/container/tooltip.html instead of an ID?

I attempted to do thi开发者_运维知识库s:

YAHOO.example.container.tt1 = new YAHOO.widget.Tooltip(
    YAHOO.util.Dom.getElementsByClassName('annotation-rating'), {
        context:"ctx",
        text:"My text was set using the 'text' configuration property"});

YAHOO.example.container.tt2 = new YAHOO.widget.Tooltip(
    YAHOO.util.Dom.getElementsByClassName('annotation-rating'), {
        context:"link" });


Looking at the docs it looks like you switched the id and context parameters.

The id parameter seems to be for the ids of the individual generated tooltips (pass null since we aren't using them?) and the context argument is for the element(s) that are being converted to tooltips:

YAHOO.example.container.tt1 = new YAHOO.widget.Tooltip( null, {
    context: YAHOO.util.Dom.getElementsByClassName('annotation-rating'),
    text:"My text was set using the 'text' configuration property"
});

Caveat - I don't really use YUI so I don't know if this works...


Since YAHOO.widget.tooltip can only accept one element, the selector needs to be more specific:

YAHOO.util.DOM.getElementsByClassName(className, tagName, rootNode)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜