I did find similar questions but it didn't help me in my case.

Basically i show an info popover when i click on an anchor. I realize this with the following js code

$("[data-popover]").click(function(){
  var selector = $(this).data('popover');
  var popoverContentId = $(this).data('popover-content');
  var popoverPlacement = $(this).data('placement');
  var popoverWidth = $(this).data('width');
  var htmlContent = $(popoverContentId).html();
  $(selector).popover({placement: popoverPlacement, title: '', width: popoverWidth, content: htmlContent, html: true});
});

Now with this code, the first click nothing happens, but afterwards it works just fine with a single click.

How to show the popover from the first click ?

Thanks.

有帮助吗?

解决方案

$(selector).popover only enables the popover. It doesn't need to be in a click event. I would change the .click to say .each

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top