dojoAttachpoint和id之间的区别是什么。
如何显示此对话框我尝试了dijit.byId('alarmCatDialog').show()代码>dojoAttachpoint和id之间的区别是什么。,dojo,Dojo,如何显示此对话框我尝试了dijit.byId('alarmCatDialog').show() 上面的代码是一个模板,我从.js文件中调用了dijit.byId('alarmCatDialog').show()。dojoAttachPoint用于模板中,可以在小部件中使用属性值进行访问 因此,如果您发布的html用于小部件模板,那么您应该使用dojoAttachPoint。在小部件的js文件中: <div dojoType="dojo.Dialog" id="alarmCatDialog"
上面的代码是一个模板,我从.js文件中调用了
dijit.byId('alarmCatDialog').show()
。dojoAttachPoint
用于模板中,可以在小部件中使用属性值进行访问
因此,如果您发布的html用于小部件模板,那么您应该使用dojoAttachPoint
。在小部件的js文件中:
<div dojoType="dojo.Dialog" id="alarmCatDialog" bgColor="#FFFFFF"
bgOpacity="0.4" toggle="standard">
<div class='dijitInline'>
<input type='input' class='dateWidgetInput'
dojoAttachPoint='numberOfDateNode' selected="true" />
</div>
您不应该在小部件中使用id,因为id在所有dom节点中都必须是唯一的。在小部件中使用它会限制小部件在页面上的使用次数
另外,由于模板中有小部件,因此应该使用widgetsInTemplate:true
可能存在的副本
dojo.declare("MyWidget", [dijit._Widget, dijit._Templated], {
alarmCatDialog: null, // the dialog widget will be attached to this field.
templateString: dojo.cache(...),
widgetsInTemplate: true,
postCreate: function() {
this.inherited(arguments);
this.alarmCatDialog.show();
}
});