0

我在门户环境中使用 jQuery 线索提示插件,在该环境中,门户页面上可能有多个 portlet 实例。每个 portlet 都是它自己的应用程序,因此它对其他 portlet 真的一无所知。每个portlet 都需要使用线索提示插件,因此它会在需要时加载它。问题是,当多次加载提示脚本时,会产生以下错误:

$cluetip is undefined

我知道一种可能的解决方案是检查插件是否已经加载,但我尝试的每一次检查都失败了。我努力了:

if(jQuery.cluetip), if(jQuery().cluetip), if(jQuery.fn.cluetip), if(jQuery().fn.cluetip)

他们都没有工作。它们都返回未定义。

如何检查插件是否已经加载?或者,我可以实施另一种解决方案吗?

4

2 回答 2

0

您是否在文档准备功能中使用了提示提示?

$(function() {
  $('a.tips').cluetip();
});

根据您上面发布的代码,您似乎没有正确使用线索提示。您实际上不需要检查插件是否已加载。如果标题中有脚本:

<script src="jquery.js" type="text/javascript"></script>
<script src="jquery.cluetip.js" type="text/javascript"></script>

那么你只需要在我上面的例子中选择你想要的提示('a.tips'),它应该可以工作。

如果您发布您的 Javascript 和 HTML,我可以为您提供更好的答案。

于 2010-09-13T18:18:24.823 回答
0

查看 cuetip 网站的来源:

<script type="text/javascript">
$(document).ready(function() {
  $('a.tips').cluetip();

  $('#houdini').cluetip({
    splitTitle: '|', // use the invoking element's title attribute to populate the clueTip...
                     // ...and split the contents into separate divs where there is a "|"
    showTitle: false // hide the clueTip's heading
  });
});
</script>
<link rel="stylesheet" href="jquery.cluetip.css" type="text/css" />

需要注意的是,首先加载的是 jQuery.js,然后是 cuetip。

确保您的 html 看起来相同,并确保 cuetip 和 jQuery 加载正常。

于 2010-09-13T18:20:22.773 回答