Run and attach events after widget save and drag&drop of a new instance
-
Hi all,
I have spent a lot of hours looking for answers and solutions but, unfortunately, I have come to no suitable conclusion so I would like to ask for help.
I am writing a custom Widget. There are a couple of issues. It performs AJAX calls. Everything works just fine until I use one of both saving the widget or drag&drop a new instance in one of the sidebars. Then all AJAX calls are no longer available since the new refreshed instance of the Widget is in different scope. This issue I have fixed by adding a portion of JavaScript code in the widget instance form but unfortunately with every save of the widget without page reload this code is multiplied and after the second save if I trigger my AJAX call by change of a certain drop-down menu I now get 2 AJAX calls, after the third save of the widget the new change of the drop-down would trigger 3 AJAX calls and so on.
The problem is in adding new and new copies of the particular JavaScript code so my question is does anyone have any idea how to re-bind the JavaScript actions to the drop-down menu after the widget save and how to trigger the same AJAX call on the Widget save itself?
I would like to thank everyone in advance for the help. I would not bother but I am already going crazy ??
- The topic ‘Run and attach events after widget save and drag&drop of a new instance’ is closed to new replies.