I have a bunch of elements dynamically created and I'm able to show the popover calling this script:
$('.gantt').popover({
selector: '.bar',
title: 'Test title',
content: 'Test content',
trigger: 'hover',
placement: function() { return 'top' },
container: 'body'
});
Now, I need to dynamically pass title and content from within a function and then I did like so:
[...]
onItemMouseover: function(elm, data) {
elm.popover({
selector: '.bar',
title: data.title,
content: data.content,
trigger: 'hover',
placement: function() { return 'top' },
container: 'body'
});
}
[...]
But the popover is not opening. Is there something missing?
If i call elm.remove()
the element is being removed, so elm is triggering correctly the DOM element.
This is a patch, probably there's a better and official way of doing this, but I solved this way:
If you have a better solution, please share.
Here's the code:
var popoverContent
$(document).ready(function () {
createGantt(data);
$('.gantt').popover({
[...]
content: function () {
return popoverContent;
},
[...]
});
}
function createGantt(data) {
$('.gantt').gantt({
[...]
onItemMouseover: function(elm, data) {
popoverContent = data.detailContent;
},
});
};