How to automatically close the bootstrap modal dialog after a minute
Try
var myModal = $('#myModal').on('shown', function () {
clearTimeout(myModal.data('hideInteval'))
var id = setTimeout(function(){
myModal.modal('hide');
});
myModal.data('hideInteval', id);
})
You can use setTimeout
in conjuction with the shown callback.
$('#myModal').on('shown', function() {
// remove previous timeouts if it's opened more than once.
clearTimeout(myModalTimeout);
// hide it after a minute
myModalTimeout = setTimeout(function() {
$('#myModal').modal('hide');
}, 6e4);
});
You can use this as :
setTimeout(function(){$('#myModal').modal('hide')},3000);