ians ians - 11 months ago 84
Javascript Question

Dojo Query returns undefined

I am trying to get a DOM element by class and not sure why its returning undefined. I can query the parent element without any problems. Here is my code:

var contentPane = query('.contentPane', this.map.infoWindow.domNode)[0];
var header = query('.header', this.map.infoWindow.domNode)[0];


The output in console:


<div class="contentPane">
<div class="esriViewPopup" id="esri_dijit__PopupRenderer_1" widgetid="esri_dijit__PopupRenderer_1">
<div class="mainSection">
<div class="header" dojoattachpoint="_title"></div>
<div class="hzLine"></div>
<div dojoattachpoint="_description"></div>
<div class="break"></div>
<div class="attachmentsSection hidden">
<div class="mediaSection hidden">
<div class="editSummarySection hidden" dojoattachpoint="_editSummarySection">

Answer Source

the .header was not rendered at the time of query. I have resolved this by using query when the containing function was completed.