markp3rry
markp3rry

Reputation: 734

Bootstrap popover on injected html button

I have injected a button like this:

$(panelBody).append('<input type="button" id="pink" class="btn btn-success btn-sm" value="SWIFT" /> '); 

but can't get a Bootstrap 3.0 Popover to render next to it when I click. Tried this inside $document.ready():

$(document).on('popover', '#pink', function(e){
    e.preventDefault();
    //console.log('clonk');
});

but nothing. Any ideas?

Upvotes: 0

Views: 445

Answers (1)

mccannf
mccannf

Reputation: 16659

You can now use the selector option when creating dynamic popovers:

$(panelBody).append('<input type="button" id="pink" class="btn btn-success btn-sm" value="SWIFT" rel="popover" title="A Title" data-content="This is the content of the popover" />');

$('body').popover({
                    selector: '[rel=popover]'
});

$(document).on('show.bs.popover', function(e) {
    console.log('clonk');
});

Fiddle here

Upvotes: 1

Related Questions