bootstrap popover: reload content with ajax

后端 未结 5 1411
予麋鹿
予麋鹿 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:24

    This work form me: Inizialize popover on document ready (data is a json with HTML and size of element found)

         $.ajax({
    url: "/alpha/annuncio/scegliGestione",
    success: function (data) {
        $('#notifiche').popover(
            {
                title:"Le tue notifiche",
                placement:'bottom',
                trigger:'manual'
            });
        $('#notifiche').find(".badge").text(data.size);
    
    }
    

    });

    On the trigger event of popover you must in sequence toggle the popover (show or hide instead), make popover-content empty and finally append data.html

    $("#notifiche").click(function(){
    
         $.get("/alpha/annuncio/scegliGestione", function(data) {
             $('#notifiche').popover('toggle')
             $("body").find('.popover-content').empty()
             $("body").find('.popover-content').append(data.html);
    
             $('#notifiche').find(".badge").text(data.size);
         });
        /* */
    
     });
    

提交回复
热议问题