cleung

pop onSelectionChange() not calling?

Discussion created by cleung on Aug 7, 2012
Hi,

I am trying to use the the popup to display data from identify results.  For each of the identified features, I need to make a ajax call to fetch data from a webservice in order to populate the content of the popup.  I figured the best way to do it is to create a function, which will be called by the popup.onSelectionChange event.  Below is my code:



//step 1: create popup
var popup= new esri.dijit.Popup(null,dojo.create("div"));
this.map = new esri.Map(mapId,{extent: this.basemap.initialExtent,  infoWindow:popup});

//step 2: identify on mouse click
dojo.connect(this.map,"onClick",this,this._handleMapClick);

_handleMapClick: function(evt) {
    identifyParams.geometry = evt.mapPoint; 
    var deferred = identifyTask.execute(identifyParams);

      deferred.addCallback(function(response) {    
          // response is an array of identify result objects   
          // Let's return an array of features.
         
            return dojo.map(response, function(result) {
            var feature = result.feature;
            var template = new esri.InfoTemplate();
            feature.setInfoTemplate(template);
            var record = feature.attributes;
            var name = record.NAME;
            template.setContent("<b>"+name+"</b><hr />");
            return feature;
          });
        });




    //step 3: show info window with results
    this.map.infoWindow.setFeatures([ deferred ]);
    this.map.infoWindow.show(this.map.toScreen(evt.mapPoint),this.map.getInfoWindowAnchor(evt.screenPoint));
}

//step 4: create listener
   
    dojo.connect(this.map.infoWindow,"onSelectionChange",function(){
    var graphic = popup.getSelectedFeature();
    console.log(graphic);
  });


the problem is the onSelectionChange function is never called as I am not able to see any console log.  Is there something wrong with my code/ syntax?

Thanks,
Connie

Outcomes