Expand my Community achievements bar.

SOLVED

Custom Code Running Twice

Avatar

Level 1
Level 1

I have custom code that is being triggered by a drop down event on the main page. When I tried testing out the library for functionality it worked, but when I tested it again by closing and reopening the drop down it cached the script causing it to run twice, and oddly breaking the functionality. It's using Core - History Change event, could that be causing the issue or is this likely caused by something else I'm not aware of?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

If you're able to use the History Change event, then that means the dropdown is causing the browser's navigation history to be updated every time the dropdown is opened and/or closed. So every time the navigation history gets updated, the History Change event gets triggered, and your Rule runs accordingly.

Furthermore, it sounds like you want to the dropdown open to be tracked for the first time only, and not subsequent times. To limit the number of times that the Rule runs, you can consider using the Core > Max Frequency condition:

yuhuisg_0-1643867303818.png

 

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

If you're able to use the History Change event, then that means the dropdown is causing the browser's navigation history to be updated every time the dropdown is opened and/or closed. So every time the navigation history gets updated, the History Change event gets triggered, and your Rule runs accordingly.

Furthermore, it sounds like you want to the dropdown open to be tracked for the first time only, and not subsequent times. To limit the number of times that the Rule runs, you can consider using the Core > Max Frequency condition:

yuhuisg_0-1643867303818.png