简体   繁体   中英

Trigger event on bootstrap modal load

I have a page that displays several items, when clicking on an item's title, it fetches content and displays it in a modal , content is fetched using href target :

<div class="tile-title">
    <a href="/get/content" data-target="#ModalDetailPoi" data-toggle="modal" class="feed_item_summary">Title</a>
</div>

I would like to do something once the content is loaded, so I tried to use the events loaded.bs.modal, show.bs.modal, shown.bs.modal but they don't ever seem to be triggered :

jQuery('.feed_i').on('loaded.bs.modal', function(e){
    console.log('azer');
});

Am I missing something ?

Why don't you try:

jQuery(document).on('loaded.bs.modal', function(e){
    console.log('azer');
});

usually the modals are added at the end of the document, and the events are not per se triggered on the events that opened the popup.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM