【问题标题】:close popover outside popover but inside stay open在popover外面关闭popover但里面保持打开
【发布时间】:2012-11-05 15:29:28
【问题描述】:

当您在弹出框外部单击时是否可以关闭引导弹出框,但在弹出框内部单击时它会保持打开状态。我知道这已经在here 中讨论过,但是当您在弹出框内单击时,这个也会关闭。

这是他们的演示:http://jsfiddle.net/Sherbrow/e6Gt8/

    var $poped = $('.poped');
$poped.popover();

// Trigger for the popover
$poped.each(function() {
    var $this = $(this);
    $this.on('hover',function() {
            var popover = $this.data('popover');
            var shown = popover && popover.tip().is(':visible');
            if(shown) return;        // Avoids flashing
            $this.popover('show');
    });
});

// Trigger for the hiding
 $('html').on('click.popover.data-api',function() {
    $poped.popover('hide');
});

【问题讨论】:

    标签: javascript jquery html twitter-bootstrap


    【解决方案1】:

    看看http://jsfiddle.net/VcwUm/

    // Trigger for the hiding
    $('html').on('click.popover.data-api',function(e) {
         if($(e.target).has('.poped').length == 1){
             $poped.popover('hide');
         } else {
             return false;
         }
    });
    

    我所做的只是检查目标元素是否有一个具有特定类的子元素来决定我是否应该关闭弹出窗口。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多