Bootstrap Popover works after one click - JavaScript

帅比萌擦擦* 提交于 2019-12-04 09:52:10

In your code, first time you click on button the popover start to init only, so until the second click, you see the effect,

I'm not sure about the version popover which you used. As the resource which I have found, they are using the jquery also.

https://github.com/klaas4/jQuery.popover/blob/master/demo.html

You can init the popover first, and then trigger click for it from any button which you want First approach, bind popover directly into button

$(function(){
    $("[name=usernameL]").popover({trigger: 'click'});
});

Second appoach, bind popover from a content div, and show popup from a button click

$("#divcontent").popover({trigger: 'click'});
$("[name=usernameL]").click(function(){$("#divcontent").trigger('click')});

What about this?

usernameL.onclick = function(e){
   $("#" + e.currentTarget.id).popover({html : true}).popover('show');
}

try this

usernameL.onclick = function(e){
   $("#" + e.currentTarget.id).popover({html : true});//Initializes popover
   $("#" + e.currentTarget.id).popover('show');//show popover
}

try the jquery style,

i suppose the button is id usernameL

$('#usernameL').click(function(){
$(this).popover();
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!