0

Okay so if this was to do with a click event i would know to do something like ...

$('body').on('click','.element',function(){
     ....do something
});

But the code i have here is:

$('.checkout .popbtn').popover({
    trigger: 'manual',
    html: true,
    container: 'body',
    placement: 'bottom',
    animation: false,
    content: function(){
        return $('#popover').html();
    }
});

.popbtn is the dynamically generated element.

How can i get around this?

Thanks

Matthew Smart
  • 341
  • 3
  • 16

2 Answers2

0

When your button gets added to the page, call your code.

0

Use DOMNodeInserted to get when the element is created on the page

$('body').on('DOMNodeInserted', '.popbtn', function () { $('.checkout .popbtn').popover({ trigger: 'manual', html: true, container: 'body', placement: 'bottom', animation: false, content: function(){ return $('#popover').html(); } }); });

Velimir Tchatchevsky
  • 2,812
  • 1
  • 16
  • 21