2016-03-04 94 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()