我使用如下代码:
$(".reply").popover({
content: "Loading...",
placement: "bottom"
});
$(".reply").popover("toggle");
Run Code Online (Sandbox Code Playgroud)
这正确地创建了popover及其内容.我想在不关闭弹出窗口的情况下将新数据加载到弹出框中.
我尝试过以下方法:
var thisVal = $(this);
$.ajax({
type: "POST",
async: false,
url: "Getdes",
data: { id: ID }
}).success(function(data) {
thisVal.attr("data-content", data);
});
Run Code Online (Sandbox Code Playgroud)
在此调用之后,元素中的数据将被更改,但不会显示在显示的弹出框中.
我该怎么办?
这是链接的html,即:
<a href="javascript:void(0);" style="font-size: 3em; color: #222" class="popover-test" id="directNavPrev" data-title="Previous Result Row" data-content="Previous Result Row">
«</a>
Run Code Online (Sandbox Code Playgroud)
是的,我正在调用.popover()进行初始化,弹出窗口工作正常.我可以毫不费力地更新内容.只是不是标题.我试过"prev.data('title','new title')",甚至尝试重新初始化"prev.popover({title:'new title'});" 没有骰子......谢谢.
function SetDirectNavigationPlaceholder() {
//debugger;
var item = $("#movementType :selected").val();
var direct = $('#directNavigation');
var prev = $('#directNavPrev');
var next = $('#directNavNext');
switch (item) {
case "result":
$('#bookTypeSection').addClass('hide');
direct.val('Result Row from 1 - 150');
prev.attr('data-title', "Previous Result Row");
next.attr('data-title', "Next Result Row");
prev.attr('data-content', "Check it! this will contain the information for the previous result<table><tr><td>blah</td><td>blah</td></tr><tr><td>blah</td><td>blah</td></tr><tr><td>blah</td><td>blah</td></tr><tr><td>blah</td><td>blah</td></tr></table>");
next.attr('data-content', "Check it! this will contain the …
Run Code Online (Sandbox Code Playgroud)