简体   繁体   English

Jquery易选项卡中页面之间的冲突,尝试使用jquery noconflict解决

[英]Conflict between pages in Jquery easy tabs, trying to solve with jquery noconflict

I have an easy tabs page,with three different pages(TAB1,TAB2,TAB3). 我有一个简单的标签页,其中包含三个不同的页面(TAB1,TAB2,TAB3)。

Tab.php Tab.php

Tab1|Tab2|Tab3 Tab1 | Tab2 | Tab3

//Tab1 has an slider plugin(with Jquery UI) //Tab2 has an autocomplete for select list // Tab1具有滑块插件(带有Jquery UI)// Tab2具有选择列表的自动完成功能

The conflict come from because two function wants to use jquery variable. 冲突来自因为两个函数要使用jquery变量。

Two pages contains jquery plugins but with only jquery version(jquery-1.11.1.min.js) 两页包含jquery插件,但只有jquery版本(jquery-1.11.1.min.js)

The tabs only works properly(elements showing,jquery methods correctly running) when only one tabs is enabled(just commenting the link). 仅启用一个选项卡(仅注释链接)时,这些选项卡才能正常工作(显示元素,jquery方法正确运行)。

I use the jquery no conlict to try to solve this problem(before that there was conflict between the main tab page and the invidual page): 我使用无冲突的jQuery尝试解决此问题(在主选项卡页面和个人页面之间存在冲突之前):

<script type="text/javascript" src="jquery-1.11.1.min.js"></script>     
<script type="text/javascript">   
 var s = $.noConflict();
</script>    

So on the sub page(tab1) i use like: 所以在子页面(tab1)上我像这样使用:

s(document).ready(function(){.....}

I also try to define a second shortcut(first i try to use the same 's' there too) : 我还尝试定义第二个快捷方式(首先我也尝试在其中使用相同的“ s”):

<script type="text/javascript" src="jquery-1.11.1.min.js"></script>     
<script type="text/javascript">     
var j = $.noConflict();
 var s = $.noConflict();
    </script> 

to use this at the Tab2 page.It was not a solution for me.Diseable Tab1 and using 'j' also works good. 不能在Tab2页面上使用它,这对我来说不是解决方案.Diseable Tab1并使用'j'也很好。

One more importent thing is the firts downloaded page shown correctly each time,so i know the conflict is becuse of the jquery variable(overwrite it or something like this). 另一个重要的事情是每次下载的正确下载的页面都正确显示,所以我知道冲突是因为jquery变量(覆盖它或类似的东西)。

I try to find a solution by my self but i couldn't.Please help me 我试图自行寻找解决方案,但我找不到。请帮助我

  • Update1: 更新1:

As i note before i made a lot of research before that: Jquery tabs conflicting with revolution slider 如前所述,在此之前我做了很多研究: jQuery选项卡与Revolution滑块冲突

This question is very similar for my problem,but the difference i have more tabs,more conflict so i thought if i use more shortcut it will solve the issue. 这个问题与我的问题非常相似,但是区别在于我有更多的选项卡,更多的冲突,所以我认为如果我使用更多的快捷方式将可以解决问题。

  • Update2: It is more interfering between the plugins than conflict. Update2:插件之间的干扰多于冲突。 using 使用

    var s = $.noConflict(true); var s = $ .noConflict(true);

totally throw awey the full page,even the tabs does not want to work First the tab.php load,it is using the jquery global variable, than if i click on Tab1 it is also wants to use the global variable, After if i click on Tab2 also need jquery variable So bumm the interfering is ready 完全丢了整个页面,甚至选项卡都无法正常工作首先是tab.php加载,它正在使用jquery全局变量,而不是如果我单击Tab1,它也想要使用全局变量,如果单击在Tab2上也需要jquery变量,所以bumm的干扰已经准备好

  • Update3: After a lot of research,i found the problem is not with the noconflict. Update3:经过大量研究,我发现问题不在于noconflict。 The Tab2(upload.php) page is correctly rendered when i full reload the page. 当我完全重新加载该页面时,将正确呈现Tab2(upload.php)页面。

     s(document).ready(function(s) {//without the ready it does not rendered even after F5 

    s("#modell").select2(); s(“#modell”)。select2(); }); });

I believe that you are trying to load jQuery with a different variable name. 我相信您正在尝试使用其他变量名加载jQuery。 I would suggest that you use: 我建议您使用:

$.noConflict();
jQuery( document ).ready(function( blah ) {
    //You can now use blah as the jquery method (e.g. blah("#button").click();)
});

I've made an example here: http://jsfiddle.net/me66st8w/ . 我在这里做了一个例子: http : //jsfiddle.net/me66st8w/ You can find out more about this in the official documentation here: http://api.jquery.com/jquery.noconflict/ . 您可以在以下官方文档中找到有关此内容的更多信息: http : //api.jquery.com/jquery.noconflict/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM