I'm trying to figure out how to respond to dialog:afterclose
only once, and I'm not having any luck getting the syntax right (and I'm having trouble finding resources because most search results refer to jquery.once, which has been removed). Here's my best guess:
(function ($, Drupal) {
Drupal.behaviors.MyCustomModule = {
attach(context) {
const $window = $(once('MyCustomModule', window, context));
$window.on('dialog:afterclose', (e) => {
console.log('closed');
});
}
}
})(jQuery, Drupal);
That never fires. If I change $window
to $(window)
it fires, but eight times. Can anyone point me in the right direction? Thanks in advance.