Select to view content in your preferred language

view.popup.watch being fired twice

3474
11
Jump to solution
06-07-2017 02:45 PM
EvonFranklin
Regular Contributor

I am attempting to display my own custom popup when a user clicks on the MapImageLayer with the following code:

view.popup.watch("visible", function(visible) {
                view.popup.visible = false;
                if(visible){
                   var attr = view.popup.features[0].attributes;
                   $('.popup-table-container').remove();
                   var newPopup = formatPopup(attr);
                   $('body').append(newPopup);
                   $(newPopup).css({top: ($(window).height()/2)+'px',left: ($(window).width()/2)+'px'});
                }
            });‍‍‍‍‍‍‍‍‍‍

I try to close the default popup in the first line then second line I actually populate my own. I would like to stop this event from being fired twice with a single click, as a query is made twice which slows down the popup processing.

Tags (1)
0 Kudos
11 Replies
EvonFranklin
Regular Contributor

Thanks for your guidance, going forward with this solution and now I have learnt how to tackle property changes. Thanks a lot.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Evon,

   Great, Don't forget to mark this question as answered.

0 Kudos