开发者

JavaScript not being loaded. Tried everything I can think of

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 开发者_StackOverflow社区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


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/


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.


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');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜