2015-01-06 187 views
0

我試圖在懸停按鈕時彈出窗口的外觀。AngularStrap懸停彈出窗口

示例代碼:

<button data-content="some data with links" data-auto-close="1" data-placement="bottom" bs-popover html='true' data-trigger="hover">Popover</button> 

當我懸停按鈕的酥料餅確實出現。但問題是當我將鼠標移動到彈出窗口時,它會消失。我如何在移動到它時留下彈出窗口?當我點擊其上的內容鏈接時,如何隱藏彈出窗口?

回答

0

對於完全相同的東西,有一個fiddle demo。希望能幫助到你。

HTML:

<p id='container'> 
<button class='btn btn-primary btn-large' data-popover="true" data-html=true data-content="<a href='http://www.wojt.eu' target='blank' >click me, I'll try not to disappear</a>">hover here</button> 
</p> 

JS:

var originalLeave = $.fn.popover.Constructor.prototype.leave; 
$.fn.popover.Constructor.prototype.leave = function(obj){ 
    var self = obj instanceof this.constructor ? 
    obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) 
    var container, timeout; 

    originalLeave.call(this, obj); 

    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); 
     //Let's monitor popover content instead 
     container.one('mouseleave', function(){ 
     $.fn.popover.Constructor.prototype.leave.call(self, self); 
     }); 
    }) 
    } 
}; 


$('body').popover({ selector: '[data-popover]', trigger: 'click hover', placement: 'auto', delay: {show: 50, hide: 400}}); 
+0

現在的問題是AngularStrap。不是Bootstrap。 – djxak

相關問題