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

时间:2015-09-28 08:04:05

标签: html css twitter-bootstrap bugzilla bootstrap-popover

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

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

Jsfiddle

注意:问题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>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:2)

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

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

代码:

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

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

相关问题