j.silver Posted November 10, 2015 Share Posted November 10, 2015 Hi, For all pages, there is a language link in the header that is created with the help of a jQuery link. For only one page, however, there is another jQuery link (besides the first jQuery) to make a text collapsible/uncollapsible. I placed both links along with their associated js files before the closing body tag. All pages are fine, except the one having the two jQuery links--it has resulted in the disappearance of a text of another anchor link in the header not related to any function of the jQueries. It seems that the jQuery affecting the language link (anchor) is also affecting the other anchor of the header. How to make the second jQuery link not affect the other anchor link? Links are listed below. <script type= "text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"></script> <script type= "text/javascript" src= "./js/collabsible.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script> <script src="js/languageswitcher.js"></script> Link to comment Share on other sites More sharing options...
dsonesuk Posted November 10, 2015 Share Posted November 10, 2015 Are you sure you require both jquery lib link, usually you just require latest. Link to comment Share on other sites More sharing options...
j.silver Posted November 10, 2015 Author Share Posted November 10, 2015 I have commented out the second link pertaining to the language list, leaving the first link and both links to the js files, it has resulted in a total disappearance of the language links while the bottom anchor link continued to have no text. Link to comment Share on other sites More sharing options...
dsonesuk Posted November 10, 2015 Share Posted November 10, 2015 Do you get error saying a required file is required? are you sure the text is being hidden somehow, it would help to have relevant html and css, maybe js as else i will get BORED with guessing. Link to comment Share on other sites More sharing options...
justsomeguy Posted November 10, 2015 Share Posted November 10, 2015 If you include jQuery a second time then you overwrite the first one. That collapsible plugin that you included goes away when you overwrite jQuery with a different version. The solution is to make all of the code work with one version of jQuery, not to "make the second jQuery link not affect the other anchor link". You're overwriting the entire library by including a different version, in this case you're overwriting a newer version and plugins with an older version. You can expect things to stop working if you do that. Link to comment Share on other sites More sharing options...
j.silver Posted November 10, 2015 Author Share Posted November 10, 2015 I have commented out the second link pertaining to the language list, leaving the first link and both links to the js files, it has resulted in a total disappearance of the language links while the bottom anchor link continued to have no text. The above explains what happens when I keep just one jQuery link. Not only it is not solving the first problem, it additionally creates a problem of having the language links (drop down menu) disappearing completely. Link to comment Share on other sites More sharing options...
j.silver Posted November 10, 2015 Author Share Posted November 10, 2015 The second jQuery link did not override the functionality of the first--clapping/uncollapsing, which is the function of the first link, is still working fine. Link to comment Share on other sites More sharing options...
dsonesuk Posted November 10, 2015 Share Posted November 10, 2015 It depends, if you are using older version of jquery code not supported anymore in current newer version you will probably see for example '.live() is not a function' error, where you would have to update the code to use the newer supported method OR use .noConflict() to use a different Jquery naming convention specific to the older version instead of '$' or 'jQuery', I'm sure i have been through this before? and supplied link how to properly implement this. Link to comment Share on other sites More sharing options...
justsomeguy Posted November 10, 2015 Share Posted November 10, 2015 The above explains what happens when I keep just one jQuery link. Not only it is not solving the first problem, it additionally creates a problem of having the language links (drop down menu) disappearing completely.And the solution is to rewrite all jQuery code to use the same version of jQuery and to only do what you want it to do. The solution is not a second duplicate version of jQuery that overwrites the first one. The solution is also not to copy and paste a bunch of independent pieces of jQuery written for different versions and just expect everything to work with no changes. You need to understand the code and figure out what it's doing so you can change the jQuery 1.x code into code that uses version 2 of jQuery. The second jQuery link did not override the functionality of the first--clapping/uncollapsing, which is the function of the first link, is still working fine.If you want to argue with me that's fine, but I guarantee that including that version 1.5.x of jQuery will completely overwrite the version 2.x that you already included. I'm not going to say that it will instantly break everything, I'm saying that you are completely replacing one version of jQuery with another one. That's what happens when you include multiple versions. There is only 1 jQuery object in Javascript, including another version of the library does not add a second jQuery object, it overwrites the first one. Link to comment Share on other sites More sharing options...
j.silver Posted November 10, 2015 Author Share Posted November 10, 2015 The matter we have addresses before, dsonesuk, and the link you supplied was not on a similar issue, it was on how to separate css and/or jQuery links between the head and bottom of the body tags. On this matter, I think there should be a way of having just one most recent link to jQuery library but which enables both required functions to take place: collapsible/uncollapsible text and language links (flags beside language name), both of which would not affect the other anchor links in the header. Link to comment Share on other sites More sharing options...
justsomeguy Posted November 10, 2015 Share Posted November 10, 2015 On this matter, I think there should be a way of having just one most recent link to jQuery library but which enables both required functions to take place: collapsible/uncollapsible text and language links (flags beside language name), both of which would not affect the other anchor links in the header.That's correct. So, stick with the latest version of jQuery and then debug the non-working code to figure out why it doesn't run with that version of jQuery. Link to comment Share on other sites More sharing options...
dsonesuk Posted November 10, 2015 Share Posted November 10, 2015 It was this topic http://w3schools.invisionzone.com/index.php?showtopic=54250&findpost=298167 post#4 which has link to .noConflict() exaplain how to use different libraries other than jQuery, AND another version of jQuery, to prevent conflict. Link to comment Share on other sites More sharing options...
j.silver Posted November 10, 2015 Author Share Posted November 10, 2015 Thanks again, dsonesuk. I will play with some codes of the provided link and see what I can come up with. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now