I post the following content on PopStash Twitter, which contains the link for which I want to listen for clicks:
<div id="popover-content"> <a id="link" href="#">click</a> </div>
I use the button to open a popover that contains the above content:
<button id="trigger" data-placement="bottom" title="title">Reveal popover</button>
Then I bind the button to popover and use the jQuery click() function, trying to listen for clicks on the link contained in popover:
$(function(){ $('#trigger').popover({ html: true, content: function() { return $('#popover-content').html(); } }); $('#link').click(function() { alert('beep'); }); });
However, by clicking a button to open a popover, and then clicking a link, the click does not seem to be detected as described above. My understanding of DOM and javascript and jQuery is pretty limited, so I'm not sure what is going on here. How can you select / listen for actions on elements contained in popover?
Link: Travel Companions in Bootstrap
source share