【问题标题】:Dojo: set content pane widgetid attributeDojo:设置内容窗格的 widgetid 属性
【发布时间】:2011-11-25 17:59:46
【问题描述】:

如何设置内容窗格的 widgetid 属性?

new dijit.layout.ContentPane({
    content: "<p>Optionally set new content now</p>",
    style: "height:125px",
    // I can set id, but widgetid will differ
    id: 'someId',
    // no effect
    widgetid: 'myWidgetId',
    // still fail
    widgetId: 'how can I set you, God damn it?!'
}

我需要它来使用 dijit.byId() 查找内容窗格,因为此方法通过它的 widgetid 属性获取元素。

【问题讨论】:

    标签: dojo


    【解决方案1】:

    在以编程方式构建小部件时,您已经传递了一个 Id。

    在您的情况下,您应该能够通过以下方式检索您的小部件:

    dijit.byId('someId');
    

    dijit.byId 所需的 id 位于小部件的“id”属性中,而不是 widgetId 属性中。

    见:http://dojotoolkit.org/reference-guide/dijit/info.html#locating-widgets

    【讨论】:

      【解决方案2】:

      您可以在创建小部件后设置 widgetId 属性。

      var w = new dijit.layout.ContentPane({
          content: "<p>Optionally set new content now</p>",
          style: "height:125px"
      }
      
      w.domNode.setAttribute("widgetId", "customWidgetId");
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-04-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多