Jump to content
TrepaNation~

Scripts interfering with one another

Recommended Posts

Hello there. I am implementing a JavaSript menu into my company's website, but seemed to have run into a snag. An existing script on the page is interfering with the new JavaScript menu. It is the JGlideMenu found here: http://www.sonicradish.com/labs/jGlideMenu/current/index.htmlI am using the inline example found on their page. I have the menu placed in a PHP side bar that acts as a persistent navigation that is conditionally fixed. The sidebar uses JQuery to switch from a static postion to a fixed position when reaching a certain scroll point. The JGlideMenu works great until I do any scrolling of the page. At that point the menu no longer functions. Instead the "rel" link (#tile_002), which is the next "slide" of the menu is placed at the end of the url. You can check out our website here to see what I'm talking about: mlkishigo.com/home-2012.html If I disable the conditionally fixed jquery it corrects the problem with JGlideMenu. But obviously I need them both to work. Any advice you have would be VERY MUCH appreciated. And please let me know if you need any other info to trouble shoot this. Thanks!

Share this post


Link to post
Share on other sites

This line: var $jx = jQuery.noConflict(); in the floating menu script causes the "$" object used by jQuery to become undefined, which causes the other script that relies on it to no longer work. That code runs when the page is scrolled.

Share this post


Link to post
Share on other sites

I would try taking that line out.

Share this post


Link to post
Share on other sites

One or the other script will need to be rewritten. The scroll script is probably smaller, so you should replace any reference in that script to the variable "$jx" with the variable "$".

Share this post


Link to post
Share on other sites

Correct, the scroll script is much shorter. There were only 3 instances of "$jx" so I quickly changed them to "$". But it still had the same problem. The JGlide worked but no persistent scroll. I went on to change it to "$nc" (for no conflict) in case "$" was referenced elsewhere. Still broken. Any other ideas?

Share this post


Link to post
Share on other sites

The variable name is not the problem, noConflict is the problem because it deletes the $ object that the other script needs. If you have any call at all to noConflict then that script will not work. You need to remove the noConflict line and use the normal "$" variable to refer to the jQuery object instead of the other variable that they use. Your updated code just uses a new variable name for the return value of noConflict. The variable name is not the problem, the use of noConflict is the problem.

Share this post


Link to post
Share on other sites

Thanks so much for the advice justsomeguy! Through your input I managed to get it to work!! Mind you I have absolutely no idea WHY it worked, because js is greek to me... What I did was change "$jx = jQuery.noConflict();" to "$jx = jQuery;". I checked the site and there are no adverse effects of making this change. If you know of some reason this is not good please let me know. But at this time I am a happy camper with things functioning as intended.

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