I need to change the popover content inside the bootstrap popover frequently. To make that i created the popover with the content, for the next time i destroyed the popover and created again. But its not working as expected. The issue is its only working on even times, ie. for the 1st time it works for second its not working for third its working and so on.
I have created my scenario as
HTML
<div id="today_not_to_doctr">
note
</div>
<button id="test">
haii
</button>
Javascript
var i = 0;
var content = "<div>haiii</div>" + i;
$('#today_not_to_doctr').popover({
title: "<h5>Note to Doctor</h5>",
content: content,
html: true,
placement: "bottom",
viewport: {
selector: 'body',
padding: 20
}
});
$('#test').on('click', function() {
i++;
content = "<div>haiii</div>" + i;
$('#today_not_to_doctr').popover('destroy');
$('#today_not_to_doctr').popover({
title: "<h5>Note to Doctor</h5>",
content: content,
html: true,
placement: "bottom",
viewport: {
selector: 'body',
padding: 20
}
});
});
I have replicated the issue in the fiddle https://jsfiddle.net/sulusfiddle/b8omeph2/