Reputation: 543
I've used off()
for the modal but the alert
is firing multiple times the second time the modal triggered, any ideas why this is happening and how I can stop it?
$('#my_modal').modal('show').off('shown.bs.modal').on('shown.bs.modal', function() {
$('#head').load('example.com/email.html', function(){
$.getScript('jquery.min.js', function(data){
alert('debug');
})
});
});
Upvotes: 2
Views: 197
Reputation: 58432
Once your you have bound .on('shown.bs.modal'
it will be fired everytime your modal loads.
If you want to unbind it after the first showing, try this:
$('#my_modal').modal('show').on('shown.bs.modal', function() {
$('#my_modal').off('shown.bs.modal'); // might be able to use $(this).off('shown.bs.modal');
$('#head').load('example.com/email.html', function(){
$.getScript('jquery.min.js', function(data){
alert('debug');
})
});
});
Upvotes: 1