Jump to content

Scripts interfering with one another


TrepaNation~

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!

Link to comment
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.

Link to comment
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?

Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...