【问题标题】:Twitter Bootstrap popover not working on first clickTwitter Bootstrap弹出窗口在第一次点击时不起作用
【发布时间】:2016-01-21 06:45:06
【问题描述】:

当我点击一个锚点时,我正在显示一个弹出框。但是弹出框不会在第一次点击时触发,它如何在第二次点击时起作用。

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:

$(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();
        }
    });    
});

这是我的小提琴:https://jsfiddle.net/47pef6g8/

我发现了类似的问题,但对我的情况没有帮助。

请帮忙。提前致谢。

【问题讨论】:

  • 添加你的代码 jsfiddle

标签: javascript jquery html twitter-bootstrap


【解决方案1】:

查看您的代码很清楚您正在初始化单击时的弹出框。因此,需要单击两次才能显示弹出框。我对您的建议是在加载文档时初始化弹出框。

根据您的问题检查示例Fiddle

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

希望这会有所帮助。

-帮助:)

【讨论】:

  • 太好了,我刚刚在加载时进行了初始化,一切看起来都不错。
  • 感谢这个明确的解决方案!!!
猜你喜欢
  • 2012-01-12
  • 2012-09-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多