Jump to content
j.silver

More Than Two jQueries Links

Recommended Posts

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="js/languageswitcher.js"></script>

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...