Dojo.query not finding elements in widget second time around

2
When connecting event handlers to an element in my Widget's DOM, it works fine the first time the widget loads, but when an update occurs, the elements, even though they exist, cannot be found. I've used dojo.query(id), query(this.domNode).query(id) and even though when I output to the console using both this.domNode and this.domNode.innerHTML the ids are clearly visible. I even did a string search in this.domNode.innerHTML and found the IDs exist there. Anybody here have experienced this quirky behaviour before? The third time the widget updates, everything works fine again.
asked
1 answers
0

dojo.query is used for finding html nodes by name class or id. If you have the id you can also use dojo.byId. If you have the widget id you should use dijit.byId.

if you do want to use dojo.query you have to add a # in front of the id. Also see the following examples.

 // all <h3> elements
dojo.query('h3')
// all <h3> elements which are first-child of their parent node
dojo.query('h3:first-child')
// a node with id="main"
dojo.query('#main')
// all <h3> elements within a node with id="main"
dojo.query('#main h3')
// a <div> with an id="main"
dojo.query('div#main')
// all <h3> elements within a div with id="main"
dojo.query('div#main h3')
// all <h3> elements that are immediate children of a <div>, within node with id="main"
dojo.query('#main div > h3')
// all nodes with class="foo"
dojo.query('.foo')
// all nodes with classes "foo" and "bar"
dojo.query('.foo.bar')
// all <h3> elements that are immediate children of a node with id="main"
dojo.query('#main > h3')
answered