Dojo/query and Webappbuilder layerlist widget (LayerListView.js)

2637
2
Jump to solution
06-04-2015 10:46 AM
TimJacobsen
New Contributor III

I'm trying to modify LayerListView.js of the webappbuilder layer list widget, so the image of the noLegend-image class will change based on the layer.

To accomplish this I tried adding the else-if to the dojo query below.  Based on the HTML/CSS in the attachment, how should the else-if be filled to populate the img class based on the tr class value.  Maybe this is the wrong approach but it seems the most obvious.

Dojo Query:

var imageName:

if (layerInfo.isTable){

     imageName = 'images/table.png';

}

else if query () == 'yourLayer' {

     imageName = 'images/yourLayer.png';

}

else {

     imageName = 'imageName = 'images/noLegend.png';

}

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Tim,

  Unless I am misinterpreting the code and your intent then what you are asking is not doable. You are asking for the proper code to query an attribute of a element that is yet to be created and added to the DOM.  I think this is what you are after:

      var imageName;
      if (layerInfo.isTable) {
        imageName = 'images/table.png';
      } else if (layerInfo.id === 'yourlayer'){
        imageName = 'images/yourLayer.png';
      } else {
        imageName = 'images/noLegend.png';
      }

View solution in original post

2 Replies
RobertScheitlin__GISP
MVP Emeritus

Tim,

  Unless I am misinterpreting the code and your intent then what you are asking is not doable. You are asking for the proper code to query an attribute of a element that is yet to be created and added to the DOM.  I think this is what you are after:

      var imageName;
      if (layerInfo.isTable) {
        imageName = 'images/table.png';
      } else if (layerInfo.id === 'yourlayer'){
        imageName = 'images/yourLayer.png';
      } else {
        imageName = 'images/noLegend.png';
      }
TimJacobsen
New Contributor III

That was it, thanks!

0 Kudos