AnswerBun.com

How can I add a Dismiss Button to a Webform Modal Conformation?

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.

One Answer

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

Add your own answers!

Related Questions

” a field on Manage display

1  Asked on February 6, 2021 by carrotandme

   

Display Entity Reference field twice, with different display modes

1  Asked on February 3, 2021 by paul-canning

     

Media html not rendering in blocks

1  Asked on February 3, 2021 by kristoffer-rom

   

How can I programmatically change the view mode?

4  Asked on February 3, 2021 by jmzea

   

How do I avoid API calls are cached?

2  Asked on February 2, 2021 by user1648228

 

Custom JSON api normalizer is not initiated

0  Asked on February 1, 2021 by kevinvhengst

   

Suddenly unable to add a field to a new content type

1  Asked on January 31, 2021 by leif

     

an error when changing the date form

1  Asked on January 30, 2021 by mahdi-alikhasi

 

Display content based on taxonomy with view

2  Asked on January 30, 2021

 

Why is my code called again written on build form?

0  Asked on January 29, 2021 by namit-garg

     

How to change path of taxonomy facet

1  Asked on January 24, 2021 by rahulkumar-it

   

Form field not show on Ajax Callback even the callback is called

1  Asked on January 23, 2021 by emad-karhely

     

Features to import content types

2  Asked on January 18, 2021 by webmaster-pf

   

Redirect user to previous page after registration

2  Asked on January 15, 2021 by lbogdan

     

field_info_field: how to define the content type name?

1  Asked on January 14, 2021 by bruno-von-paris

   

Ask a Question

Get help from others!

© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP