Reputation: 454
I want to close popover automatically after a delay time. but its showing an error error image
$('#prev_button').popover('show');
$('#prev_button').on('shown.bs.popover', function() {
var $pop = $(this);
setTimeout(function() {
$pop.popover('destroy');
}, 1000);
});
bootstrap.bundle.js is included to ensure popover method works. Can't figure out a solution
PS: using v4.1 bootstrap
Upvotes: 10
Views: 11234
Reputation: 23859
As of version 4.1, the method destroy
has been replaced by dispose
. You can find more details here.
$pop.popover('dispose');
Upvotes: 27
Reputation: 3675
The Popover plugin is similar to tooltips. To destroy the shown popover you can use the following code-snippet:
$pop.popover('destroy'); // jQuery < 4.1
$pop.popover('dispose'); // jQuery > 4.1
You can also remove all created popovers from your DOM via .popover
class (each popover has an id, so by knowing the IDs you can be more precise)
$('.popover').remove();
Upvotes: 0
Reputation: 663
Please share bootstrap version details for better help & it would be better if you could prepare a jsfiddle.
Here is a jsfiddle link where you can find your code working with Bootstrap 3.0.
If you are using Bootstrap 4 following reference would help.
Some suggestions:
1. If you just intend to close it you should use hide rather than destroy.
2. You can also directly pass delay as an option to delay show or hide such that
delay: {
show: "500",
hide: "1000"
},
HTH
Upvotes: 1