2011-11-25 43 views
1

如何設置內容窗格widgetid屬性?Dojo:設置內容窗格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屬性獲取元素。

回答

1

您可以在創建小部件後設置widgetId屬性。

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

w.domNode.setAttribute("widgetId", "customWidgetId");