简体   繁体   English

Twitter Bootstrap popover无法在第一次点击时工作

[英]Twitter Bootstrap popover not working on first click

I am showing a popover when i click on an anchor. 当我点击一个锚点时,我正在显示一个弹出窗口。 But the popover is not triggering on the first click, how ever it works on the second click. 但是弹出窗口没有在第一次点击时触发,它在第二次点击时是如何工作的。

HTML: HTML:

    <!-- Pop Check -->
<div class="popover-markup">
   <input class="checkbox-inline" type="checkbox" value="Option1">
   <a href="javascript:void(0)" class="trigger" data-placement="bottom" tooltip="Manage Users">Option1</a>
   <!-- Popup Content-->
   <div class="content hide">
      <div class="head hide">Select Users For Option1<span class="close_popover"><i class="fa fa-times"></i></span></div>
      <div>
         <label class="checkbox-inline">
         <input type="checkbox" id="" class="si_DSCM" value="user6"> User 6
         </label>
      </div>
   </div>
</div>

JS: JS:

$(document).on('click', ".popover-markup>.trigger", function () { 

    $(this).popover({
        html: true,
        title: function () {
            return $(this).parent().find('.head').html();
        },
        content: function () {
            return $(this).parent().find('.content').html();
        }
    });    
});

This is my Fiddle: https://jsfiddle.net/47pef6g8/ 这是我的小提琴: https//jsfiddle.net/47pef6g8/

I found similar questions but it didn't help me in my case. 我发现了类似的问题,但在我的案例中并没有帮助我。

Please help. 请帮忙。 Thanks in advance. 提前致谢。

Looking at your code its very clear that you are initializing the popover on the click. 查看您的代码非常清楚您正在初始化点击上的弹出窗口。 Therefore it is taking two clicks to display the popover. 因此,需要两次单击才能显示弹出窗口。 My suggestion to you would be to initialize popover on load of the document. 我的建议是在文档加载时初始化popover。

Check the sample Fiddle based on your question. 根据您的问题检查样品小提琴

$('[data-toggle="popover"]').popover({
    html: true,
    title: function () {
        return $(this).parent().find('.head').html();
    },
    content: function () {
        return $(this).parent().find('.content').html();
    }
}); 

Hope this helps. 希望这可以帮助。

-Help :) -救命 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM