由于 jQuery 冲突,Maphilight 插件无法在 Wordpress 中运行

发布于 2024-11-03 04:26:42 字数 1648 浏览 1 评论 0原文

我在美国地图上使用 maphilight 插件,这样当鼠标滑过时,各州就会改变颜色。

(http://plugins.jquery.com/project/maphilight

带有演示:

http:// davidlynch.org/js/maphilight/docs/demo_usa.html

我的 header.php 中有以下内容(我使用的是 wordpress):

<script language="javascript" type="text/javascript" src="<?php bloginfo('url'); ?>/wp-content/themes/adventure-journal-child/js/jquery-1.2.3.pack.js"></script>
<script language="javascript" type="text/javascript" src="<?php bloginfo('url'); ?>/wp-content/themes/adventure-journal-child/js/jquery.metadata.min.js"></script>
<script language="javascript" type="text/javascript" src="<?php bloginfo('url'); ?>/wp-content/themes/adventure-journal-child/js/jquery.maphilight.js"></script>

它工作得很好,直到我安装了带有短代码的样式(SWS), http://plugins.righthere.com/styles-with-shortcodes/,能够添加也使用 JQuery 的选项卡和工具提示。

两人因此产生冲突。因此,一旦删除了与 maphilights 关联的 jQuery 代码,我的选项卡和工具提示就可以工作了。我一直在阅读有关此内容的文章,并意识到将代码加载到标头中无论如何都不理想。 我的问题是:如何让 maphilight 工作而不引起冲突?

我尝试过:

 <script type="text/javascript">
    jQuery.noConflict();
    jQuery(function() {
        jQuery('.map').maphilight({fade: false}); /*set true for fading hover effect*/
           });
</script>   

maphilight 插件可以使用与我的带有简码的样式相同的 jQuery 吗?那我该怎么办呢?

我想我需要在functions.php中使用wp_enqueue_script,但我不知道如何去做。

我的最终目标是能够将鼠标悬停在地图上的某个州,它会突出显示,并弹出一个工具提示,其中包含文本和链接。 非常感谢!

I am using the maphilight plugin on a US map so that when the mouse rolls over, the states change colors.

(http://plugins.jquery.com/project/maphilight

with demo:

http://davidlynch.org/js/maphilight/docs/demo_usa.html)

I had the following in my header.php (I am using wordpress):

<script language="javascript" type="text/javascript" src="<?php bloginfo('url'); ?>/wp-content/themes/adventure-journal-child/js/jquery-1.2.3.pack.js"></script>
<script language="javascript" type="text/javascript" src="<?php bloginfo('url'); ?>/wp-content/themes/adventure-journal-child/js/jquery.metadata.min.js"></script>
<script language="javascript" type="text/javascript" src="<?php bloginfo('url'); ?>/wp-content/themes/adventure-journal-child/js/jquery.maphilight.js"></script>

It was working great until I installed Styles with Shortcodes (SWS), http://plugins.righthere.com/styles-with-shortcodes/, to be able to add tabs and tooltips which uses JQuery as well.

The two were causing conflict. So once the jQuery code associated with maphilights was removed my tabs and tooltips work. I have been reading about this and realize loading the code into the header is not ideal anyways.
My question is: How can I get maphilight to work without causing conflict?

I tried:

 <script type="text/javascript">
    jQuery.noConflict();
    jQuery(function() {
        jQuery('.map').maphilight({fade: false}); /*set true for fading hover effect*/
           });
</script>   

Can the maphilight plugin use the same jQuery as my Styles with Shortcodes? Is so how do I do this?

I think I need to use wp_enqueue_script in the functions.php, but am not sure how to go about doing it.

My end goal is to be able to roll over a state on the map and it highlights and a tooltip pops up with text and links inside.
Thanks so much!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我的奇迹 2024-11-10 04:26:42

解决这个问题有点困难,因为这些是付费插件,我们看不到您链接中的冲突,但您可以尝试的一件事是更新您的 jquery,您目前使用的是 1.4.2,但它们使用的是 1.5。 2

http://code.jquery.com/jquery-1.5.2.min.js

It is kind of hard to troubleshoot this one since those are paid plugins and we can't see the conflict in your link, but one thing you might try is update your jquery, You are currently on 1.4.2 but they are on 1.5.2

http://code.jquery.com/jquery-1.5.2.min.js

感情旳空白 2024-11-10 04:26:42

您最好使用 wp_enqueue_script 函数。在了解该功能之前,我在几个 WordPress 网站上遇到了类似的问题。

You would be better off using the wp_enqueue_script function instead. I ran into similar issues on a couple WordPress sites until I learned about that function.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文