bootstrap popover: reload content with ajax

后端 未结 5 1351
予麋鹿
予麋鹿 2021-02-01 10:52

I\'m having trouble reloading content of a bootstrap popover with ajax. Here\'s some code: http://pastie.org/3960102

The second ajax request (when I click on \"a.close\"

5条回答
  •  独厮守ぢ
    2021-02-01 11:15

    Instead of resetting the data-content attribute, you are able to directly access the popover tooltip content.

    Replace the following line:

    t.attr('data-content', r);
    

    with this working code:

    t.data('popover').tip().html(r);
    

    Update 2012

    As Pigueiras pointed out in his comment, that would destroy the default template for the popover. A better solution is to replace the contents of .popover-content:

    t.data('popover').tip().find('.popover-content').empty().append(r);
    

    Update 2016

    Thanks to another comment, here is the working code for Bootstrap 3:

    t.data('bs.popover').tip().find('.popover-content').empty().append(r);
    

提交回复
热议问题