Can not trigger any javascript events inside popover in bootstrap

jquery, twitter-bootstrap

Solution

As Michael pointed out in his answer, the popover element does not exist in the HTML until the link is clicked. So the `click` handler can't attach to it until after the link is clicked. So you can either move the click handler into the popover call, or use the jquery `on` delegate, like this:

$('.location').on('click','.text-btn',function () {
    alert('What\'s going on!');
    //$('.text-btn').toggle();
});

See this work in the fiddle

What this does is the following: It attaches a click handler to the element with the `location` class. When anything inside this element gets clicked (such as the `text-btn` element), the event bubbles up and triggers this handler. However, the `on` handler listens only to events that are triggered by specific elements (in this case elements that have the `text-btn` class). Since the the handler is attached to the `.location` element and this element is non-dynamic, it will always be available.

Problem

Ok, I've been dealing with this issue for a couple of days and I just found out that I can't trigger any events inside a bootstrap popover. I even tried to trigger an `alert()` and it does nothing. I have a popover with a button in it. When you click the button the text on it change. Any help? Fiddle here. Thanks.

Original source