【发布时间】:2014-02-21 11:44:27
【问题描述】:
我有一个页面,其中有一个 jquery 网格和一个带有和图标的链接。我需要显示一个弹出框并在弹出框内显示一个表单。但是当用户点击另一个链接(应该出现另一个弹出框)或页面上除弹出框之外的任何其他位置时,弹出框应该关闭。
我写的当前代码不起作用。
当前代码:
链接的HTML代码(这个div是网格中的一列,每一行的rowid都会不同):
<div rowid="5" class="action-buttons">
<a href="javascript:void(0);" class="blue editRow">
<i class="icon-pencil bigger-130"></i>
</a>
<a href="javascript:void(0);" class="green markComplete">
<i class="icon-check bigger-130"></i>
</a>
</div>
Javascript 代码:
$('#grid-table').on('click','.editRow',function(e){
$(this).popover({
html: true,
title: 'Popover Title<a class="close" href="#">×</a>',
content: '<a>This one works fine!!</a>' //Content can change based on rowId
});
$(this).popover('show');
e.stopPropagation();
$('body').click(function (e) {
if (($('.popover').has(e.target).length == 0) || $(e.target).is('.close')) {
$(this).popover('hide');
}
});
});
【问题讨论】:
-
能否请您为此创建一个fiddle?
标签: javascript jquery html twitter-bootstrap