Mark
Mark

Reputation: 1

Dojo PostCreate issue

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'
      size="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

Upvotes: 0

Views: 1436

Answers (1)

peller
peller

Reputation: 4543

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.

Upvotes: 1

Related Questions