jQuery Extensions Causing Premature DOMReady event with J25 Plugin

171 views
Skip to first unread message

SonarEclipse

unread,
Jul 15, 2012, 4:39:26 AM7/15/12
to joomla-de...@googlegroups.com
Hello,

I am building a plugin which loads in several 3rd-party libraries including jQuery 1.7 (and then executing some scripts with those 3rd-party libraries), and I am encountering an issue where any extensions which already use jQuery will cause the DOMReady event to fire prematurely, thus causing numerous errors.

Is there a way to avoid this, such that the documentready event can be fired as per normally?

Thanks in advance.

SonarEclipse

unread,
Jul 15, 2012, 4:58:22 AM7/15/12
to joomla-de...@googlegroups.com
Just to be a little more specific (as it appears I still may not have correctly diagnosed the problem), the 3rd-party libraries' methods are returning 'undefined' when called.

For example, I have loaded in the chosen.js libarary.  When calling via console, this:

$("select").not("#editor_selection, #lang").chosen()

yields:

TypeError: Object [object Object] has no method 'chosen'
  1. argumentsArray[2]
  2. get messagefunction () { [native code] }
  3. get stackfunction () { [native code] }
  4. set messagefunction () { [native code] }
  5. set stackfunction () { [native code] }
  6. type"undefined_method"
  7. __proto__Error

Once again, this problem only occurs when in the view of a component which uses jQuery.

Thanks for any help.

Amit Nigam

unread,
Jul 16, 2012, 1:28:36 AM7/16/12
to joomla-de...@googlegroups.com
Hi There, why dont you try this and let me know
instead of using '$' directly use this like following

var $_ = jQuery;

$_("select").not("#editor_selection, #lang").chosen()

Thanks and Regards,
Amit.

subtextproductions

unread,
Jul 19, 2012, 10:59:44 AM7/19/12
to joomla-de...@googlegroups.com
Are you loading jQuery in noConflict mode? If not, are you allowing the CMS to load the MooTools library? If more than one javascript framework is loaded then they are both trying to use the $ function in different ways. I have a plugin at https://github.com/subtext/plg_filterjavascript which attempts to filter all the loaded javascript and only allow one framework to be run at a time. I use it to substitute the default MooTools library with Prototype.js.
Reply all
Reply to author
Forward
0 new messages