I'm not pretty sure about your html so I did a complete example:
html:
Open Modal
js:
$(function(){
$('#myModal').on('show.bs.modal', function(){
var myModal = $(this);
clearTimeout(myModal.data('hideInterval'));
myModal.data('hideInterval', setTimeout(function(){
myModal.modal('hide');
}, 3000));
});
});
The main difference with your code:
- I set a time for timeout (3000)
- I set myModal variable inside
callback