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中文网
PHP中文网Original
2017-06-17 17:42:201226browse

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>

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!

Statement:
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