Skip to content
Advertisement

Add custom class from link to drupal-modal drupal 8 with bootstrap theme

In Drupal 8, with the bootstrap theme when you create a link with class and data-dialog-type attributes like the bellow code:

JavaScript

You will open content of the page in #drupal-modal element that has these html wrappers:

JavaScript

This structure is generated in: themesbootstrapjsmodal.js how we can see on the link.

How do I modify it so that I can pass a class name to the #drupal-modal element from the link a.use-ajax? The class name text could be value of an attribute of the link.

Specifically I’d like to add modal-lg or modal-sm classes or some custom ones.

Advertisement

Answer

Thanks to @Waxi i have read through the other issue and I came up with this:

JavaScript

Had to use mousedown event, coz click wouldn’t work as it is blocked by something. Then it is getting content of data-dialog-class so it can be added to the .modal-dialog element after the modal actually loads, because its html is not present before that

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement