如何动态地为Dojo的对象赋值

时间:2013-09-18 03:08:46

标签: dojo

我想用Dojo实现TooltipDialog,尽管对话框显示效果很好,但我仍然不知道如何更改提示的内容,我的代码如下:

var _tipContent;

require([
        "dijit/TooltipDialog",
        "dijit/popup",
        "dojo/on",
        "dojo/dom",
        "dojo/domReady!"
    ], function (TooltipDialog, popup, on, dom) {
        var myTooltipDialog = new TooltipDialog({
            id: 'myTooltipDialog',
            style: "width: 300px;",
            content: _tipContent,
            onMouseLeave: function () {
                popup.close(myTooltipDialog);
            }
        });

        on(dom.byId('TriggerBlock'), 'mouseover', function () {
            popup.open({
                popup: myTooltipDialog,
                around: dom.byId('TriggerBlock')
            });
        });
    });

function onMouseOverGraphics(sender, eventArgs) {
  _tipContent = "I wanna change the tip's content according to the current position, the x coordinate: " + eventArgs.clientX;

}

1 个答案:

答案 0 :(得分:1)

请尝试使用此代码:

dijit.showTooltip("This is the tool tip content",
     //this is the dom where you want the tooltip to show
     select.domNode,
     //this is an attribute to get where the tooltip of the dom
     select.get('tooltipPosition'),
     //this is the position or the side of where the tooltip will sho
     !select.isLeftToRight()
     );