I have a bootstrap popover that I cannot seem to get to show up inside the element I am calling it on, next to my mouse. I have searched far and wide through the popper.js documentation and have tried using the 'offset' modifier, as well as adjusting just about every other parameter I could think of, in different configurations, but it seems no matter what I do the popover stubbornly wants to be positioned towards one of its four string directions and won't show up inside the element I am calling it on, next to my current cursor position.
Here's an example to give you an idea of what I have tried. Again, I am trying to have the popover popup positioned next to where my mouse click occurs, within a large div.
$(".a_large_div").click(function(e) {
var relX = e.pageX - parentOffset.left;
var relY = e.pageY - parentOffset.top;
var height = $('.popover').height();
$(this).popover({
placement: 'top',
offset:'-'+(relX + 1000)+'px,-'+(relY)+'px',
title: 'My Popover',
html:true,
trigger: 'manual',
modifiers: {
flip: { enabled: false },
inner: { order: 700, enabled: true },
applyStyle: { order: 900, enabled: true, fn: (data, options) =>
{
data.styles.left = "1000px";
console.log(data, options);
return data;
}
},
offset: { order: 0, enabled: true, offset: '-'+(relX + 1000)+'px,-'+(relY)+'px' },
},
boundary: this,
content: function() {return $("#my_popover_content").html();},
delay: 100
}).on('show.bs.popover', function() {
// execute some code
}).on('shown.bs.popover', function() {
// execute some code
}).on('inserted.bs.popover', function() {
Object.assign($('.popover')[0].style,{left:""+relX+"px !important",top:""+relY+"px !important"});
}).on('hidden.bs.popover', function() {
// execute some code
}).on('hide.bs.popover', function() {
// execute some code
});
$(this).popover('toggle');
$('.popover').css('left', (relX) + 'px');
$('.popover').css('top', (relY) + 'px');
I have tried all these different positioning methods but to no avail, it seems the 'placement' modifier overrides all of them and Im not sure at what point during the popper.js update process I would be able to override it's positioning. Thanks in advance for all your help.