2016-03-04 126 views
0

我有Bootstrap 2應用程序顯示一個SVG,當我點擊任何path元素我得到Bootstrap 2彈出窗口的預期。關閉引導2彈出窗口

$('body').popover 
    'selector': 'path' 
    'container': 'body' 
    'html': true 
    'width': '360px' 
    'title':() -> 
     item = LOOKUP[this.id] 
     '<a href="' + '/graphs.horizon/port/'+item['device']+'/'+item['physical_port'] + '">' + item['device'] + '/' + item['physical_port'] + '</a>' + '<button type="button" id="close" class="close">&times;</button>' 
    'content':() -> 
     this.id 
     item = LOOKUP[this.id] 
     url = '/graphs.horizon/utilisation/'+item['device']+'/'+item['physical_port']+'?layout=naked' 
     '<iframe src="'+url+'" frameBorder="0" width="360px" height="180px"></iframe>' 
    'trigger': 'click' 
    'placement': 'right' 

所以我天真地添加一個一般click事件類似如下:

$(document).on 'click', '.popover .close',() -> 
    console.log 'hello %o', $(this).parents('.popover') 
    $(this).parents('.popover').popover('hide') 

然而,它似乎並沒有工作。我收到調試問候消息,但.popover('hide')似乎沒有做任何事情,除了打印調試消息。

在控制檯中我也嘗試$('.popover').popover('hide'),並且沒有做任何事情,但要麼只使用選擇顯示在div對象的列表,因爲我期望的那樣。

回答

0

這工作:

$(document).on 'click', '.popover .close',() -> 
    console.log 'hello %o', $(this).parents('.popover') 
    $(this).parents('.popover').hide()