0
<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>

如何显示我试过的这个对话框dijit.byId('alarmCatDialog').show();

上面的代码是一个模板,我dijit.byId('alarmCatDialog').show()从 .js 文件中调用。

4

1 回答 1

1

dojoAttachPoint在模板中使用,并且可以使用属性的值在小部件中访问。

因此,如果您发布的 html 用于小部件模板,那么您应该使用dojoAttachPoint. 在小部件的 js 文件中:

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();
  }
});

您不应该在小部件中使用 id,因为 id 在所有 dom 节点中必须是唯一的。在小部件中使用它会将小部件的使用限制为在页面上一次。

此外,由于您的模板中有小部件,您应该使用widgetsInTemplate: true

http://dojotoolkit.org/reference-guide/1.7/dijit/_Templated.html#widgetsintemplate

于 2012-06-15T23:04:10.483 回答