SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Guru
    Join Date
    Jul 2003
    Location
    england
    Posts
    822
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Question Cannot solve jQuery Conflict

    On this page I have three objects using jQuery. One is the main menu at the top, the supporting menu on the left, and the Accordion in the content.

    On all other pages in the site, the main and left menu work fine (I only have one jQuery script running). With the Accordion, it's another story. Because there is more than one script loading (from the main menu and the Accordion), the main menu and the left menu do not function correctly. So I disabled the loading of jQuery in the Accordion, but doing that disables the Accordion affect.

    Recommendation?

  2. #2
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,657
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Try running jquery conflict. I believe it's called that. Make sure your running the latest jquery and all the plugins.

  3. #3
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,200
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    It's called jQuery noConflict

    But also note that you are loading jQuery twice on your page, which is a mistake and often causes problems, so I'd address that first.

  4. #4
    SitePoint Guru
    Join Date
    Jul 2003
    Location
    england
    Posts
    822
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Question

    Quote Originally Posted by ralph.m View Post
    It's called jQuery noConflict

    But also note that you are loading jQuery twice on your page, which is a mistake and often causes problems, so I'd address that first.
    This is how the page is set up:
    The left menu is running on jQuery, but the Accordion does not work when an item is clicked.

    The main menu is loading and running jQuery.

    The Accordion needs jQuery to run, but when I removed the jQuery call (so it would run only on the Main Menu's jQuery), the Accordion is broken. I have already tried applying the 'noConflict', but it breaks the Accordion.

    If I upgrade the jQuery to 1.10.2, the Main Menu, the left menu, and the Accordion do not work.

    I have already addressed the fact that I am running two jQuery's, which is where the conflict resides. My problem is trying to understand that when I disable one jQuery call, two out of the three items needing jQuery do not work.

  5. #5
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,657
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    You should never need to run two jquerys. When you update to the latest jquery you often need to do the same with the plugins.

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,707
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by toad78 View Post
    Recommendation?
    One of your jQuery's is attempting to get jQuery 1.4.6 from google hosting, which is not a valid jQuery version. You can see all the jQuery versions at http://code.jquery.com/#jquery-all
    Version 1.4.4 is the most recent of the 1.4 series.

    Having said that though, remove all but the most recent version of jQuery on your page, that being 1.6.2, and remove the noConflict. That noConflict removes the $ symbol and is only to be used when you have some other library that also uses the $ symbol, this achieving what noConflict says. In your situation, that won't help you, so remove the noConflict.

    1. Remove all but the 1.6.2 jQuery from your page
    2. Remove the noConflict
    3. Profit
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  7. #7
    SitePoint Guru
    Join Date
    Jul 2003
    Location
    england
    Posts
    822
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by PicnicTutorials View Post
    You should never need to run two jquerys. When you update to the latest jquery you often need to do the same with the plugins.
    Yes, I realize that. What I've done now is that I'm running only one jQuery and the Accordion still isn't working, but the menus are. I went to the developer of the Accordion and their script does show it is running the version I'm loading, but for some reason this Accordion is no longer working.

  8. #8
    SitePoint Guru
    Join Date
    Jul 2003
    Location
    england
    Posts
    822
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks, paul_wilkins:

    I caught your comments after I responded with my previous post. I did exactly what you mentioned and everything is working great! I didn't realize that the 'noConflict' code was causing the raucous. I thought the whole point of the 'noConflict' was to prevent any other library from loading, but now I know that is not the case.

    Thank you!


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •