bernhard Posted February 12, 2021 Share Posted February 12, 2021 Edit: seems that it works when wrapping the code in $(document).ready(...) - can anybody explain why? Strange one... I have this in a custom JS file in the backend: $(document).on("pw-modal-closed", function(event, ui) { console.log('modal closed, do some magic'); }); console.log('loaded'); I load the page and get "loaded" in the console. I click on a link having class="pw-panel", the panel opens. I close the panel. Nothing in the console ? Any ideas? It should work IMHO: https://github.com/processwire/processwire/blob/d8945198f4a6a60dab23bd0462e8a6285369dcb9/wire/modules/Jquery/JqueryUI/modal.js#L43 Link to comment Share on other sites More sharing options...
7Studio Posted February 12, 2021 Share Posted February 12, 2021 @bernhard in your example you are listening to the modal close event - "pw-modal-closed", also you have linked a modal.js, if you are using panels then "pw-panel-closed" should do the trick I guess ? 1 Link to comment Share on other sites More sharing options...
7Studio Posted February 12, 2021 Share Posted February 12, 2021 @bernhard I didn't noticed your edit, most likely the modal does not exist in dom yet or this event wasn't defined when your script fires up - scripts order in the back, thus you may need dom ready. Small off topic, I just started to build my first process module so I would like to thank you a lot for your tutorial about adding pages in the backend ? it helps me a lot! Back on topic, I'm using modals in the module as well, and I've noticed that this event is always fired three times, so you may think about using debounce to limit it. Anyway once again huge thanks for your tutorial about process modules! ? Link to comment Share on other sites More sharing options...
bernhard Posted February 12, 2021 Author Share Posted February 12, 2021 It was indeed a typo!!! That explains why it worked in $(document).ready --> I fixed the typo by accident ? Thx @7Studio and happy that my tutorial helped. The pw backend is a great playground ? 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now