How to update bootstrap popover text?

后端 未结 9 749
长发绾君心
长发绾君心 2020-12-07 20:31

I am using bootstrap-popover to show a message beside an element.

If I want to show different text in the popover after the first time, the text does not change. Re

9条回答
  •  醉梦人生
    2020-12-07 20:51

    I found Bootstrap popover content cannot changed dynamically which introduces the setContent function. My code (hopefully helpful to someone) is therefore:

    (Noting that jquery data() isn't so good at setting as it is getting)

    // Update basket
    current = $('#basketPopover').data('content');
    newbasket = current.replace(/\d+/i,parseInt(data));
    
    $('#basketPopover').attr('data-content',newbasket);
    $('#basketPopover').setContent();
    $('#basketPopover').$tip.addClass(popover.options.placement);
    

提交回复
热议问题