AnsweredAssumed Answered

Popup Action calling function multiple times when pressed once

Question asked by a2gcarlos on Jun 26, 2018
Latest reply on Jun 26, 2018 by a2gcarlos

Dear ArcGIS community,

 

Our team is working with the  ArcGIS JavasScript API, we have implemented a popup window, that we are using to cycle through different versions of a polygon.

 

The problem that we are facing, is that the linked action is called multiple times when clicking the button once on the popup, and it only happens when using a popup.

 

If we call the function by itself it doesn't have that problem. We tried to use event.stopPropagation() on the event, but it doesn't have that method.

 

Here is the function that we use to show our polygon.

 

function prevSpot(id) {

        actualIndex = spots[id].index;

 

        if (actualIndex - 1 > -1) {

            prevIndex = actualIndex - 1;

            p = spots[id].list[prevIndex];

            temp.removeAll();

            temp.add(p);

            spots[id].index = prevIndex;

        }

    }

 

prevSpotAction = {

                                title: "Previous Spot",

                                id: "prevSpot"

                            };

 

                            view.popup.on("trigger-action", function (event) {

                                if (event.action.id === "prevSpot")

                                {

                                    prevSpot(spotId);                                   

                                }

                            });

 

                            var popUp =

                                {

                                    title: "Spot: " + String(name),

                                    content: "<div style='background-color:DarkGray;color:white'> Events: " + cntEvt + " events.</div>" +

                                        "<div style='background-color:White;color:DarkGray'> First Seen: " + fstSeen + "</div>" +

                                        "<div style='background-color:DarkGray;color:white'> Last Seen: " + lstSeen + "</div>" +

                                        "<div style='background-color:White;color:DarkGray'> Evolutions: " + n + "</div>",

                                    actions: [prevSpotAction, nextSpotAction]

                                };

Outcomes