【问题标题】:Twitter Bootstrap Popovers dynamic HTML from $.get()Twitter Bootstrap Popovers 来自 $.get() 的动态 HTML
【发布时间】:2013-11-14 05:51:27
【问题描述】:
 $('#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) 无法正常工作,因为缺少任何语法,或者这不是正确的方法?请帮忙。

【问题讨论】:

    标签: jquery twitter-bootstrap popover


    【解决方案1】:

    是的,我自己解决了,下面的代码对我有用

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-13
      相关资源
      最近更新 更多