单击选择标记选项。 Bootstrap popover关闭

时间:2021-11-12 17:14:55

I don't know english. I'm sorry to exchange meaningless phrases.

我不懂英语。我很抱歉交换无意义的短语。

Click on the Select tag option. Bootstrap popover closes.

单击“选择标记”选项。 Bootstrap popover关闭。

Jsfiddle

的jsfiddle

Note: Problem mozilla firefox browser.

注意:问题mozilla firefox浏览器。

// Bootstrap Popover
$('body').popover({
    selector: '[data-popover]',
    html: true,
    trigger: 'click hover',
    title: function() {
        return $('.select_box').html();
    },
    content: '...',
    placement: 'bottom',
    delay: {
        show: 50,
        hide: 400
    }
});
<button class='btn btn-primary' data-popover="true">hover here</button>


<div class="select_box hidden">
    <select class="form-control">
        <option>Day</option>
        <option>Week</option>
        <option>Month</option>
        <option>...</option>
    </select>
</div>

1 个解决方案

#1


1  

select elements have inconsistent behavior across browser, and the related events can be triggered in different moments.

select元素在浏览器中具有不一致的行为,并且可以在不同时刻触发相关事件。

Mantaining the jQuery one way you can check if the current target triggering the mouse leave is a select and if so rebind the mouseleave handler.

以一种方式保存jQuery,你可以检查触发鼠标离开的当前目标是否为select,如果是,则重新绑定mouseleave处理程序。

Code:

码:

if (obj.currentTarget) {
    container = $(obj.currentTarget).siblings('.popover')
    timeout = self.timeout;
    container.one('mouseenter', function () {
        //We entered the actual popover – call off the dogs
        clearTimeout(timeout);

        var bindLeave = function () {
            container.one('mouseleave', function (e) {
                if ($(e.target).is('select')) {
                    bindLeave();
                    return;
                }
                $.fn.popover.Constructor.prototype.leave.call(self, self);
            });
        }

        bindLeave();
    })
}

Demo: http://jsfiddle.net/IrvinDominin/tskf0eoL/

演示:http://jsfiddle.net/IrvinDominin/tskf0eoL/

#1


1  

select elements have inconsistent behavior across browser, and the related events can be triggered in different moments.

select元素在浏览器中具有不一致的行为,并且可以在不同时刻触发相关事件。

Mantaining the jQuery one way you can check if the current target triggering the mouse leave is a select and if so rebind the mouseleave handler.

以一种方式保存jQuery,你可以检查触发鼠标离开的当前目标是否为select,如果是,则重新绑定mouseleave处理程序。

Code:

码:

if (obj.currentTarget) {
    container = $(obj.currentTarget).siblings('.popover')
    timeout = self.timeout;
    container.one('mouseenter', function () {
        //We entered the actual popover – call off the dogs
        clearTimeout(timeout);

        var bindLeave = function () {
            container.one('mouseleave', function (e) {
                if ($(e.target).is('select')) {
                    bindLeave();
                    return;
                }
                $.fn.popover.Constructor.prototype.leave.call(self, self);
            });
        }

        bindLeave();
    })
}

Demo: http://jsfiddle.net/IrvinDominin/tskf0eoL/

演示:http://jsfiddle.net/IrvinDominin/tskf0eoL/