Event listener on popup open?

8653
3
12-20-2017 02:33 AM
LarsFagerbakke
New Contributor III

Is there a way to add an event on a popup open event? I want, based on its target, to perform a AJAX call and retrieve more data to populate the content field from a third party system.

Popup only has the "trigger-action" event that handles action within the popup.

Tags (1)
0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

Lars,

   There are actually very few events in the 4.x api. You now just watch properties. 

https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#visible 

Use view.popup.watch("visible", function(){});

RyanBohan
Occasional Contributor III

Thank you Robert, this is what I was looking for.

I was getting doubled results when the pop up was turned on and off, so I added an if statement

view.popup.watch("visible", function (popUpStatusChange) {
   if (popUpStatusChange == true) {
     console.log("Pop-up watch has been fired")
     console.log("Pop-up title is:", view.popup.title); //returns the pop up title
     console.log("Pop-up content is:", view.popup.content); //returns the pop up content
   }
});

0 Kudos