我正在使用cluetip plugin which是很棒的。我正在使用 Ajax 填充插件,但我无法在任何地方(在文档或示例中)了解如何从 ajax 回调设置标题。
线索提示是否支持通过ajax更新标题?
更新说明:
因此,下面给出的建议是有效的,因为它们可以创建标题,但在这种情况下,关闭按钮不会显示在标题中。参见下图。
最佳答案
其实,从简单的角度来看,还是很容易的。
首先要注意的是,文档中的所有线索提示仅使用一个标记布局来显示所有提示。每次触发新的线索提示时,它只会更新其标记布局并显示它。
让我们看看example如何解决您正在尝试的问题
<小时/>我为此使用了演示。所以标记是:
注意:我使用两个线索提示来模拟具有多个线索提示的案例
<a class="title" title="hello" href="http://plugins.learningjquery.com/cluetip/demo/ajax3.html" rel="http://plugins.learningjquery.com/cluetip/demo/ajax3.html">This example</a>
<a class="basic" href="http://plugins.learningjquery.com/cluetip/demo/ajax.html" rel="http://plugins.learningjquery.com/cluetip/demo/ajax.html">Basic</a>
让我们对样式进行一些小的更改,以便它正确对齐
.cluetip-close { float: right; margin-top: -40px; }
现在,我们的脚本,用于两个线索提示。
var title;
$('a.title').cluetip({
closePosition: 'top',
sticky: true,
closeText: '<img src="http://plugins.learningjquery.com/cluetip/demo/cross.png" alt="close" width="16" height="16" />Close',
ajaxCache: false,
ajaxSettings: {
success: function(data) {
title = "Your new Title";
$(this).attr("title", title); //just set the title for consistency
}
},
onShow : function(ct,c) {
$(".cluetip-title").text(title); //update the title class with the title
}
});
$('a.basic').cluetip(); //While definning another tip, it is NOT affected by previous one
完成
尽管fiddle可能不会显示出来。我已经测试过它并且它有效。
关于jquery - 当粘性: true?时,如何通过ajax回调设置crudetop工具提示的标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7961336/