Drupal Answers Asked by Webdrips on November 13, 2021
I added an extra close button to my webform confirmation modal in a Bootstrap 4 theme:
<button class="btn btn-primary" data-dismiss="modal" id="button-close-modal" type="button">OK</button>
Then I added a script to act on that button, but it doesn’t seem to do anything:
(function($) {
Drupal.behaviors.hideModal = {
attach: function(context, settings) {
$('#button-close-modal', context).on('click', function(e){
$('.webform-confirmation-modal', context).modal('hide');
});
}
};
})(jQuery);
Nothing in the console to give me a clue as to what may be happening. I tried .modal('toggle')
and that didn’t work either (although at least I could visually see a change).
I also tried $('.ui-dialog-titlebar-close', context).click();
, but that didn’t work either.
Note: I have the "Webform Bootstrap" module enabled.
Here is how I got it working:
(function($) {
Drupal.behaviors.hideModal = {
attach: function(context, settings) {
$('body', context).on('click', '#button-close-modal', function(e){
$('.webform-confirmation-modal--content', context).dialog('close');
});
}
};
})(jQuery);
Answered by Webdrips on November 13, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP