Bootstrap popover自定义模板不起作用

时间:2015-02-17 19:09:38

标签: twitter-bootstrap twitter-bootstrap-3 bootstrap-popover

我尝试使用选项将自定义模板设置为弹出窗口,但永远不会添加模板。为什么?这是代码。我需要这种方法才能工作,因为我无法使用该方法.popover(ecc ..)

HTML:

<button type="button" data-loading-text="..." data-placement="bottom" id="selectRecipientsBtn"
                                data-toggle="popover" data-trigger="manual" 
                                class="btn btn-default dropdown-toggle destinatariDiv">
                                <span class="caret"></span>
                            </button>


$('#selectRecipientsBtn').click(function(e) {
    e.preventDefault(); 
    loadManagers("<c:url value='/secure/send/managers' />");
});



function loadManagers(urlToLoad){ var popoverTemplate = '<div class="popover popover-managers"><div class="arrow"></div>'+
            '<h3 class="popover-title"></h3><div class="popover-content">'+
            '</div><div class="popover-footer"></div></div>';function loadManagers(urlToLoad) {

$("#selectRecipientsBtn").button('loading');

$.ajax({
    type : 'GET',
    url : urlToLoad,
    success : function(data, status, xhr) {
        $("#selectRecipientsBtn").button('reset');
        $("#selectRecipientsBtn").data("bs.popover").options.html=true;
        $("#selectRecipientsBtn").data("bs.popover").options.title='ciao';
        $("#selectRecipientsBtn").data("bs.popover").options.trigger='manual';
        $("#selectRecipientsBtn").data("bs.popover").options.content=data;
        $("#selectRecipientsBtn").data("bs.popover").options.template= popoverTemplate; 
        $("#selectRecipientsBtn").popover("show");

    },
    error : function(xhr, status, error) {
        alert("error");
    },
});

}

2 个答案:

答案 0 :(得分:3)

你试过了吗?

$("#selectRecipientsBtn").popover({
    title:'ciao',
    trigger:'manual',
    content:data,
    template:popoverTemplate
});
$("#selectRecipientsBtn").popover("show");

答案 1 :(得分:0)

$('#selectRecipientsBtn').popover({
    html:true,
    title: 'managers',
    trigger : 'manual',
    placement : 'bottom',
    template: popoverMessageTemplate
});


$('#selectRecipientsBtn').click(function(e) {
    e.preventDefault(); 
    $("#selectRecipientsBtn").button('loading');

    $.ajax({
        type : 'GET',
        url : "<c:url value='/secure/send/managers' />",
        success : function(data, status, xhr) {
            $("#selectRecipientsBtn").button('reset');
            $("#selectRecipientsBtn").data("bs.popover").options.html=true;
            $("#selectRecipientsBtn").data("bs.popover").options.content=data;
            $("#selectRecipientsBtn").popover("show");          
        },
        error : function(xhr, status, error) {
            alert("error");
        },
    });
});