bootstrap jquery show.bs.modal event won't fire

前端 未结 19 2458
小蘑菇
小蘑菇 2020-11-28 07:29

i\'m using the modal example from the bootstrap 3 docs. the modal works. however i need to access the show.bs.modal event when it fires. for now i\'m just trying:



        
19条回答
  •  不知归路
    2020-11-28 08:01

    Wrap your function in $(document).ready(function() {, or more simply, $(function() {. In CoffeeScript, this would look like

    $ ->
      $('#myModal').on 'show.bs.modal', (event)->
    

    Without it, the JavaScript is executing before the document loads, and #myModal is not part of the DOM yet. Here is the Bootstrap reference.

提交回复
热议问题