【发布时间】:2012-02-15 03:05:43
【问题描述】:
我正在使用Jquery Cluetip 作为我的工具提示。 工具提示内容通过 Cluetip 中的 AJAX 功能加载。在加载的内容中我想使用 Javascript 来增加可用性。
index.html:
<img src="edit.png" title="Test" class="popup" rel="ajax-content.html">
onLoad.js:
$('.popup').cluetip({activation: 'click'});
ajax-content.html:
<script language="javascript" type="text/javascript">
alert('Hello world!');
</script>
Test content.
结果是点击时出现的工具提示,标题为:'Test',内容:'Test content' 和 no提示“Hello world!”。 FireBug 不显示脚本或控制台错误。
有什么帮助吗?
编辑:
我想通了。
Cluetip 有一个处理 ajax 的默认动作:
ajaxProcess: function(data) {
data = data.replace(/<(script|style|title)[^<]+<\/(script|style|title)>/gm, '').replace(/<(link|meta)[^>]+>/g,'');
return data;
}
所以解决方法是:
$('.popup').cluetip({
activation: 'click'.
ajaxProcess: function(data) {
return data;
}
});
我不确定为什么 Cluetip 会删除所有脚本/样式/标题,可能是为了防止错误。
【问题讨论】:
标签: jquery ajax tooltip cluetip