Twitter Bootstrap弹出来自$ .get()的动态HTML

时间:2013-11-14 05:51:28

标签: jquery twitter-bootstrap popover

 $('#editPersonal').popover({
        trigger: 'click',
        placement: 'bottom',
        html: true,
        content: function () {
            var url = "/Profile/Edit"; // the url to the controller
            var id = $(this).attr('data-id');
            var res = "";
           **return  $.get(url + '/' + id, data)**
        }           
        });

如何将HTML从$ .get方法返回到popover?  返回$ .get(url +'/'+ id,数据)在任何语法上都没有工作,或者这不是正确的方法吗?请帮忙。

1 个答案:

答案 0 :(得分:0)

是的,我自己解决了,下面的代码正在为我工​​作

 <div id="editPersonal"
                             class="btn btn-lg btn-danger"
                             data-toggle="popover"
                             data-html=true 
                             data-id="@Model.Id">Hover to toggle popover</div>

$(document).ready(function () {
    $('#editPersonal').popover({

        trigger: 'click',
        placement: 'bottom',
        html: true,
        content: function () {

            var p = $(this);
            var url = "/Profile/Edit";
            var id = $(this).attr('data-id');
            $.get(url + '/' + id, function (data) {
                p.attr("data-content", data);
                p.popover('show');
            });


        }
    });