0

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.

user3334226
  • 151
  • 1
  • 5
  • 15
  • i tried the fiddle you gave, but it seems works just fine, what's the problem with that ? – Gagantous Sep 29 '17 at 15:38
  • Works fine for me too in Chrome, what browser are you trying with? – LAROmega Sep 29 '17 at 15:40
  • Toggle works for few clicks (4-5 times) and then do not work. Which chrome version are you trying on? Mine version is Version 61.0.3163.100 – user3334226 Sep 29 '17 at 17:59
  • I was able to resolve the issue. I had added the $('body').on(click) function(e) at multiple places as multiple htmls had same function and I added one for each. After I combine all with 1 single function it worked. Thanks for your help. – user3334226 Sep 29 '17 at 19:54

0 Answers0