Bootstrap 3.0.0 modal events not firing

梦想与她 提交于 2019-11-30 17:14:07

According to documentation the event name is like shown.bs.modal:

$('#imageUpload').on('shown.bs.modal', function () {
   alert('show event fired!');
});

Have a look at this FIDDLE

remove the .fade class from your modal. this worked for me.

removing the fade class on the modal element do the fix.

https://github.com/twbs/bootstrap/issues/11793

see @Fint answer

There seems to be a bug in the Bootstrap.min.css file for the modal dialog. I changed it to Bootstrap.css and the dialog is now visible.

The answer marked correct is just that, but an addition to the massive list of 'Dumb things I have done' - also be careful which DOM Element you target. It should be the outer modal Div.

For example if you are using RequireJS and a template manager like Knockout-amd-helper you might have markup like this

Parent markup:

<div class="modal fade" id="addThingModal" tabindex="-1" role="dialog" aria-labelledby="addThingModalLabel" aria-hidden="true">
    <div data-bind="module: { name: 'addThing'}"></div>
</div>

Template:

<div id="addThingTemplate" class="modal-dialog">
   ...
</div>

your script should target '#addThingModal' not '#addThingTemplate'

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!