Dojo.query not finding elements in widget second time around

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.
1 answers

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