0

The Bootstrap Popover plugin is not displaying the HTML content properly.

I have a button inside the popover and when clicking that button I need to perform some action. When I add the onclick function on the button, the button disappears from the popover.

Also, the button and popover are randomly generated so I can't use the jQuery onclick.

Can anyone help me with why the button is not displayed if I add an onclick function in the bootstrap popover?

$('.popover-menu').popover({
  'html': true,
  'placement': 'top',
  'trigger': 'manual',
  'animation': false,
  'container': 'body',
  'template': '<div class="popover popover-menu-wrapper"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"></div></div></div>',
  'content': function () {
    var content = $(this).attr('id');
    return $("#" + content + "Popover").html();
  }
});
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
  • 'Also, the button and popover are randomly generated so I can't use the jQuery onclick.' Yes you can - use a [delegated event handler](https://stackoverflow.com/questions/203198/event-binding-on-dynamically-created-elements). – Rory McCrossan Dec 10 '21 at 10:23
  • @RoryMcCrossan I have tried the same but the problem is that when ever I try to add some additional parameter to the html button it disappear from the popover. – Shashank Awasthy Dec 13 '21 at 08:16
  • Adding 'sanitize': false in the config solve my problem. – Shashank Awasthy Jan 18 '22 at 06:14

0 Answers0