How to update bootstrap popover text?

You can access the options directly using the jquery data closure dictionary like this:

$('a#test').data('bs.popover').options.content = 'new content';

This code should work fine even after first initializing the popover.


Hiya please see working demo here: http://jsfiddle.net/4g3Py/1/

I have made the changes to get your desired outcome. :)

I reckon you already know what you are doing but some example recommendations from my end as follows for sample: http://dl.dropbox.com/u/74874/test_scripts/popover/index.html# - sharing this link to give you idea for different link with different pop-over if you will see the source notice attribute data-content but what you wanted is working by the following changes.

Have a nice one and hope this helps. D'uh don't forget to up vote and accept the answer :)

Jquery Code

var i = 0;
$('a#test').click(function() {
    i += 1;

    $('a#test').popover({
        trigger: 'manual',
        placement: 'right',
        content: function() {
           var message = "Count is" + i;
             return message;
        }
    });
    $('a#test').popover("show");

});​

HTML

<a id="test">Click me</a>
​