【问题标题】:Prevent A Parent Action With Bootstrap Popover使用 Bootstrap 弹出框防止父操作
【发布时间】:2017-01-02 04:43:28
【问题描述】:

我有以下 JavaScript:

$( ".aa-list-menu-item-heading" ).click(
    function()
    {
        $( this ).find( ".aa-collapse" ).toggleClass( "glyphicon-chevron-left glyphicon-chevron-down" );
        $( this ).next( ".row" ).slideToggle();
    }
);

$("[data-toggle=popover]").popover();

popover 链接位于类 .aa-list-menu-item-heading 的子 div 中

当我点击弹出框时,它可以工作,但是 $( ".aa-list-menu-item-heading" ).click() 运行

如何防止父子弹出框对父 .click() 进行操作?

【问题讨论】:

    标签: javascript jquery html css twitter-bootstrap


    【解决方案1】:

    您“不能”,但您可以检查您的点击目标是否是您的 DIV 点击事件处理程序中的弹出框并跳过执行以防万一。

    $( ".aa-list-menu-item-heading" ).click(
        function(e)
        {
            if ($(e.target).data('toggle') !== 'popover'){
                $( this ).find( ".aa-collapse" ).toggleClass( "glyphicon-chevron-left glyphicon-chevron-down" );
                $( this ).next( ".row" ).slideToggle();
            }
        }
    );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-08-09
      • 1970-01-01
      • 2017-08-06
      • 2014-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多