I have two functions bound to a click event at two different times (using jQuery). The order in which they are fired is significant. They are firing in the correct order.
An other solution is to debounce or throttle the function.
This way you could ensure despite it firing multiple times, it only executes within a set duration. This would allow your code to work as-is.