I am monitoring a particular form for changes and want to warn the user before they attempt to navigate away from the form without submitting it. I've successfully gotten this working in all instances except for the overlay close button – because that element is bound to the
Drupal.overlay.close() function, a user is able to click it and immediately close the overlay, even though I'm listening for all
I looked inside of
modules/overlay/overlay-parent.js and see that it provides the
drupalOverlayBeforeClose event so that other scripts can respond and stop the overlay from closing if needed, but I can't figure out how to implement this. Do I just listen for this event globally, through the
$(document) or something? Or do I need to extend the Drupal object and attach my function to this event somehow?