0
 $('#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 ? return $.get(url + '/' + id, data) is not working 缺少任何语法,或者这不是正确的方法?请帮忙。

4

1 回答 1

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');
            });


        }
    });
于 2013-11-15T03:17:23.870 回答