tags:

views:

23

answers:

1

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

A: 

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.

peller
yes, correct, and I did have my own template.
Mark