2014-07-21 57 views
0

我试图将内容动态加载到Bootstrap弹出窗口中。提交表格时,我可以提醒该值;这工作正常。我不能做得到的内容#popover-thanks加载在弹出窗口中,用感谢信息替换表单。在表单提交后将动态内容加载到Bootstrap弹出窗口中

// show the popover 
$('#btn').popover({ 
    html : true, 
    placement: 'top', 
    content: function() { 
     return $('#popover-form').html(); 
    } 
}); 

// form has been submitted 
$(document).on('click', '#submit', function() { 

    var value = $('#value').val(); 

    alert(value); 

    $('#btn').popover({ 
     html : true, 
     content: function() { 
      return $('#popover-thanks').html(); 
     } 
    }); 
}); 

回答

0

,我认为你必须销毁第一酥料饼才能够使相同的元素新的:

$('#btn').popover('destroy'); 

http://getbootstrap.com/javascript/#popovers-usage

  • 另一种解决方案,你可以得到酥料饼的ID (展后)如下:

    var popoverID = $('#btn').attr("aria-describedby"); // = 'popover123456' (random number) 
    

更换内容(http://getbootstrap.com/javascript/#popovers),然后显示它:

$('#btn').popover('show'); 
+0

哈!我试图摧毁它并展示它,但不是在一起!谢谢 :) – timgavin

相关问题