Home > Web Front-end > JS Tutorial > Bootstrap Modal Event Not Fired When Modal is Shown/Hidden

Bootstrap Modal Event Not Fired When Modal is Shown/Hidden

PHP中文网
Release: 2017-06-17 17:42:20
Original
1224 people have browsed it

Problem Description

Use jQuery (3.2.1).

In the Modal of

Bootstrap (v4-alpha), if the Modal exists .fade, then the shown.bs.modal and hidden.bs.modal events The callback function will not be triggered normally.

But the triggering of the show.bs.modal and hide.bs.modal events is normal.

The difference between these two events is immediately and wait for CSS transitions to complete.

Solution

Dynamically add .fadeclass before setting the event listener:

<code>$ ->
    registerModal = $('#registerModal')
    registerModal.addClass('fade')
    registerModal.on('hidden.bs.modal', ->
        $(this).find('input').val('')
    )</code>
Copy after login

The above is the detailed content of Bootstrap Modal Event Not Fired When Modal is Shown/Hidden. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template