I have some Bootstrap-Buttons, which should show a popover when the button is clicked.
usernameL.onclick = function(e){
$("#" + e.currentTarget.id).popover({html : true});
}
When the website has loaded and I click the button a first time, nothing happens. If I click a second time, the popover opens and it works normal.
What can I do for the popover to appear on the first click?
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')});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With