开发者

Dojo PostCreate issue

开发者 https://www.devze.com 2023-01-18 17:24 出处:网络
I have a custom widget which has a content pane (among other things). In it I have a multiselect listbox. I have a assigned a dojoAttachPoint to the listbox.

I have a custom widget which has a content pane (among other things). In it I have a multiselect listbox. I have a assigned a dojoAttachPoint to the listbox.

I want to populate the listbox when the widget is created.

In postCreate I try to fill the listbox with items, but the reference to this.selectFrom (which is the dojoAttachPoint) is null.

Why would this not be available in postCreate? Any workarounds?

Thanks in advance

HTML:

<div dojoType='dijit.layout.ContentPane'>
  <select name="drop1" style='width:200px;'
      id="selectTo" dojoAttachPoint='selectTo'
      siz开发者_开发技巧e="10" multiple="multiple">
    <option value="1">second col</option>
    <option value="2">option two</option>
  </select>
</div>

JS:

postCreate: function (){
  this.inherited (arguments);
  var newOption = document.createElement('option');
  text = 'Mark Brown';
  value = '1';
  selectTo.options [this.selectTo.options.length] = new Option (name,value);
}

this.selectTo is null and it shouldn't be.

Thanks


I think dojoAttachPoint is only meaningful in templates (see dijit._Templated) Templates are separate strings/files which are used to compose widgets and are generally not used inline in the page.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号