views:

197

answers:

3

Hi.

Swimwire.com is no longer loading JavaScript properly since I installed an update to its Social module, JomSocial. It's something to do with JomSocial, I'm certain, since on the homepage no JavaScript properly works (there's a blue bar along the top that should be clickable and contain the words 'Open Control Panel', but it doesn't load). Whereas if I visit a page not displaying JomSocial content the JavaScript will happily load.

I got some help with this yesterday but unfortuantely I'm still very stuck. I'm a novice at JavaScript and Safari throws me the error

TypeError: Result of expression '$' [undefined] is not a function. /modules/mod_rokslideshow/tmpl/slideshow.js:73TypeError: Result of expression '$' [undefined] is not a function. 2/media/system/js/mootools.js:54TypeError: Type error

I'm not too sure at all how to interpret this. I'm certain that something in JomSocial is causing a conflict but don't know really how to go about addressing this.

Jack

+2  A: 

There are multiple libraries which define $; I know that jQuery and Prototype do this, not sure about MooTools (which I see in your error message). So, based on that message, I can only guess that you have, in one way or another, loaded two libraries which both use $.

The jQuery solution for this is to use noConflict: http://docs.jquery.com/Core/jQuery.noConflict. Not knowing both sides of the clash, and not being able to access the site myself, that's the best I can do.


Edit: Did you try any of the solutions that MooTools suggests? http://mootools.net/blog/2009/06/22/the-dollar-safe-mode/

Matt Ball
Mootools does have $ defined as well. The new versions let you use document.id instead in case someone else has defined $
Gordon Tucker
Thanks for your help, I've opened the site up again - sorry, I totally forgot! :DIf you examine the source, however, you will see jQuery.noConflict()... :(
Jack Webb-Heller
A: 

You have to make sure that even if you have jQuery in no conflict mode, that you have MooTools loading first. If you load jQuery, put it into no conflict mode, then load MooTools, it will fail. I wrote some documentation on this in my book: http://www.packtpub.com/files/learning-joomla-1-5-extension-development-sample-chapter-8-using-javascript-effects.pdf

If you make sure that the following call is made before jQuery gets added to the document, it should load MooTools before jQuery:

JHTML::_('behavior.mootools');
jlleblanc
+1  A: 

Your jQuery.noConflict() most likely comes after some other scripts are loaded and attempt to use $.

Another thing... jQuery.noConflict() may not work if it's included before the other library, as it's in this case.

James Logsdon