Skip to content

Instantly share code, notes, and snippets.

@Mykola-Veryha
Last active March 1, 2021 15:11
Show Gist options
  • Select an option

  • Save Mykola-Veryha/4338e749bfd811d6f43578228ad69ccc to your computer and use it in GitHub Desktop.

Select an option

Save Mykola-Veryha/4338e749bfd811d6f43578228ad69ccc to your computer and use it in GitHub Desktop.
Drupal 8 Add class to body after opening a modal window
(function ($, Drupal) {
$(window).on('dialog:beforecreate', function (e, dialog, $element, settings) {
$('body').addClass('modal-dialog-open');
});
$(window).on('dialog:beforeclose', function (e, dialog, $element, settings) {
$('body').removeClass('modal-dialog-open');
});
})(jQuery, Drupal);
add_class_to_body:
js:
js/add_class_to_body.js: {}
@Mykola-Veryha
Copy link
Copy Markdown
Author

Mykola-Veryha commented Oct 26, 2019

Create a library with the file above and attach the library to your theme or a render element

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment