I have an on(someNode, "click", someFunction) in the onOpen() of Widget.js. The problem is that if the widget is closed then reopened (2nd open), the click event on someNode fires twice. If close and reopen the widget again (3rd open), the click event fires three times, so on and so forth...
Is there a way to let the click event on someNode only fire once after reopening the widget?
I appreciate any help. Thanks!
Solved! Go to Solution.
The Widget life cycle page in the documentation might help explain this. The postCreate method happens only once when the widget is first created. The onOpen method happens every time the widget is opened. Since your on event was added during onOpen, every time the widget is opened, another event listener is added.
The other way to make sure the event is only added once would be to remove your on event in the onClose method.