So I had always hoped to avoid the whole dojo universe. The JSAPI 4.x seems to more and more inoculate against the inner workings of whatever dojo its using. But now, I'm trying to build some custom WAB widgets and see myself having unscramble some of this dojo stuff. i got a 2-part question, and question subject refers to only part 2.
Robert Scheitlin, GISP had some advice suggesting to work with dojo attachments points, as in ...
<input data-dojo-attach-point="myButton" type="button" value="Click Here">
so that in my code I could refer to this element in widget.html simply as this.myButton.
But I'm still not sure when to use the above or - provided I have added id = 'myButton', use this;
I see folks using them almost interchangeably through this forum and elsewhere. Are there some simple guiding principles?
Now for the Select. I'm making a call to a web service, ignoring geometry and just returning the feature's name. Then I populate a <select> with that, which I have called:
<select id='results' data-dojo-attach-point='results' data-dojo-type="dijit/form/Select"></select>
The following code populates a bunch of entries (or <option>'s) in that <select> with records from the service.
//Interate over features in featureset
//find desired feature attribute's value
var c = document.createElement('option');
c.innerHTML = myAttributeValue;
c.value = i;
this.results.appendChild(c); // 'results' being my dojo attach point
Next, I would like to use the dijit's event listener to watch if one of those <options>'s is selected. Again, ...
The above gets me a reference to the <select> but no attempt - such as ".value",".displayValue", "_getDisplayedValueAttr()" or ".selected" has been successful in getting me the value that's selected, and I've scoured the Dojo site for info. I can iterate over this.results.options and check the attribute selected for each one, but is there a simpler way? Thanks.