Problem with scripts conflicting

Sep 21, 2010 at 3:37 AM

I'm building menu using the 

jkmegamenu plugin

from here
http://www.javascriptkit.com/script/script2/jkmegamenu.shtml

My data comes from a list using the
jquery.SPServices-0.5.6.min.js

I'm sure the menu works because when i remove the
jquery.SPServices-0.5.6.min.js and hard code the HTML the menu does work i think the SPServces.js is conflicting with the 
jkmegamenu.js
Any ideas how to not make it conflict.Do i have to load the js in Jquery?
Thanks in Advance

 This is the way i reference the script below:

<
script type="text/javascript" src="_layouts/jQuery/jquery-1.4.2.min.js"></script> <script src="_layouts/jQuery/jkmegamenu/jkmegamenu.js" type="text/javascript"></script> <script src="_layouts/jQuery/jquery.SPServices-0.5.6.min.js" type="text/javascript"></script> <script type="text/javascript"> //jkmegamenu.definemenu("anchorid", "menuid", "mouseover|click") jkmegamenu.definemenu("megaanchor", "megamenu1", "mouseover") </script>

 

Sep 21, 2010 at 5:56 AM

Oops got it working.
After pulling my hair off. I taught i should look at the jkmegamenu.js code and i noticed
he had   $Jquery.noConflict();
commented it out and it worked like a charm

Chrs

Patrick


Coordinator
Sep 23, 2010 at 2:26 AM

Nice to see you solved it without our help!

M.

Jun 18 at 9:41 AM
I realize this is a very old thread, but it would be nice if SPServices were to appropriately handle a case where noConflict was called.

Like this if you need to support cases where jQuery.noConflict(true) is called:
(function($) {
$.fn.lazyPlugin = function(opt) { // ... }
})(jQuery || _jQuery);
Jun 18 at 1:46 PM
SPServices already properly initializes itself by using the jQuery global variable and not $ global variable, so whatever problem you had, its likely that SPServices was not the root cause.

What I have seen repeadtely as a problem is:

- Unknown to the user, the pages loads multiple versions of jQuery. SPServices will initialize using whatever version is global at the time the of initialization

- other logic is not properly referencing jQuery (ex: using global $ instead of an IIFD that creates private scoped $ that points at jQquery global variable )

Hope this helps.
Paul

-- sent from mobile