简体   繁体   中英

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).

Tab.php

Tab1|Tab2|Tab3

//Tab1 has an slider plugin(with Jquery UI) //Tab2 has an autocomplete for select list

The conflict come from because two function wants to use jquery variable.

Two pages contains jquery plugins but with only jquery version(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).

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):

<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:

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

I also try to define a second shortcut(first i try to use the same 's' there too) :

<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.

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).

I try to find a solution by my self but i couldn't.Please help me

  • Update1:

As i note before i made a lot of research before that: Jquery tabs conflicting with revolution slider

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. using

    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

  • Update3: After a lot of research,i found the problem is not with the noconflict. The Tab2(upload.php) page is correctly rendered when i full reload the page.

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

    s("#modell").select2(); });

I believe that you are trying to load jQuery with a different variable name. 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/ . You can find out more about this in the official documentation here: http://api.jquery.com/jquery.noconflict/ .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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