动态更改只有一个元素的工具提示标题我有一个tooltipster title属性一组选项,就像如下:使用tooltipster
<i class="icon-cog settings" title="
<div class='div1' onclick='follow(1,2)'>Content 1</div>
<div class='div2' ...>Content 2</div>
<div class='div3' ...>Content 3</div>
">
</i>
当点击DIV1,内容dinamically由AJAX结果更新基于以下功能:
function follow(f1,f2) {
$.get('/exe/add_followers.php?f1=' + f1 + '&f2=' + f2, function (result) {
$('.div'+f2).html('content 1 is updated to' + result.newcontent);
}, 'json');
}
的问题是,当提示被关闭,页面一直没有更新,内容返回到初始值,而不是显示更新后的值。
我试图用一个配置选项描述Here:
function follow(f1,f2) {
$.get('/exe/add_followers.php?f1=' + f1 + '&f2=' + f2, function (result) {
// $('.div'+f2).html('content 1 is updated to' + result.newcontent);
$('.settings').tooltipster('update', 'content 1 is updated to' + result.newcontent);
}, 'json');
}
然而,这种改变DIV1的内容,而删除其他的div的内容。我如何只更新div1的内容并保持其他内容不变?
== ==编辑
我更喜欢一个解决方案,没有通过所有设置的div,就像如下:
function follow(f1,f2) {
$.get('/exe/add_followers.php?f1=' + f1 + '&f2=' + f2, function (result) {
$('.settings').tooltipster('update', '
<div class='div1' onclick='follow(1,2)'>'+result.newcontent+'</div>
<div class='div2' ...>Content 2</div>
<div class='div3' ...>Content 3</div>
');
}, 'json');
}
其与title属性给出报价的问题。 – ram
@ram你能否详细说明一下?请! – afazolo
尝试使用'和“组合转义标题属性值以将html转义为字符串 – ram