Jump to content

[solved] How to listen for pw-panel-closed ?


bernhard
 Share

Recommended Posts

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

@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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...