I am trying to make sure the popover gets closed if i click anywhere on ui. Please have a look at the sample code at https://jsfiddle.net/vk23nmy8/15/ .
On click of Add, it adds rows to table. Each row has its popover. It works for first few clicks but then does not work at all. I am not sure what I am doing wrong here.Below is the code I am using to close tje pop-up.
$('body').on('click', function(e) {
var count = 0;
$("#tbody > tr").each(function() {
$('[data-toggle="popover' + count + '"]').each(function () {
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
$(this).popover('hide');
}
});
count++;
});
});
Thanks for your help.