Bootstrap modal 'loaded' event on remote fragment
Just an update here:
Bootstrap has added a loaded event.
http://getbootstrap.com/javascript/#modals
capture the 'loaded.bs.modal' event on the modal
$('#myModal').on('loaded.bs.modal', function (e) {
// do cool stuff here all day… no need to change bootstrap
})
According to both these issues:
https://github.com/twbs/bootstrap/issues/5169
https://github.com/twbs/bootstrap/pull/6846
..as of now the Bootstrap developers are digging their heels in and refusing to add a loaded
event into Bootstrap.
So instead they recommend you avoid using the data-remote
markup and load the data yourself into the modal:
$('#myModal').modal(your_options).find('.modal-body').load('request_url', function () {
// do cool stuff here all day… no need to change bootstrap
}')
The 'loaded.bs.modal' event doesn't work for me, so I have tried the 'shown.bs.modal' event and it's works fine :
$('#myModal').on('shown.bs.modal', function () {
// do cool stuff here...
});
This event is captured after the modal is shown.
I hope this will help someone :)