Re: Jquery & Joomla < 3.0

181 views
Skip to first unread message

Thomas PAPIN

unread,
Jul 20, 2012, 10:00:25 AM7/20/12
to joomla-de...@googlegroups.com
To explain a little better the "workaround" for jquery

  1. Load the jQuery 1.3 library
  2. Load the "foo" plugin library
  3. Load and execute a custom "noConflict" script

e.g.:

scripts[] = [...]
scripts[] = scripts/jquery-132.js
scripts[] = scripts/jquery.foo.js
scripts[] = scripts/jquery-noconflict.js
scripts[] = [...]

Community Documentation

Multiple different versions of jQuery co-existing

Last updated September 16, 2009. Created by Signify on September 16, 2009.
Log in to edit this page.

or:

Resolving jQuery plugin dependencies in Drupal without touching the version in core (or using jQuery Update)

Recent versions of jQuery include a noConflict() function which restore the previous definition of the $() function and, optionally, the jQuery() function.

This provides a way of using later versions of jQuery for particular purposes, without affecting the version that core and contrib are using.

Example

Problem: We want to use the "foo" jQuery plugin in our theme, but it needs jQuery 1.3.

Solution: In our theme's .info file, carefully specify the order of the scripts:

  1. Load the jQuery 1.3 library
  2. Load the "foo" plugin library
  3. Load and execute a custom "noConflict" script

e.g.:

scripts[] = [...]
scripts[] = scripts/jquery-132.js
scripts[] = scripts/jquery.foo.js
scripts[] = scripts/jquery-noconflict.js
scripts[] = [...]

------------------------------

jquery-noconflict.js looks like this:

var jQuery13 = jQuery;
jQuery.noConflict(true);

------------------------------------------

Just use jQuery13() instead of using $() or jQuery()



2012/7/20 Thomas PAPIN <thomas...@gmail.com>
Hello,

Waiting for J! 3.0 which will normally use the great jQuery.
It's still a horrible work to manage jQuery on 2.5.

Is there any plan to add a simple JHTML behaviour Jquery (just to load the jquery) the same way for all components.?

Because my problem is generally not with mootools (there are solution for that), but with website that integrate 3,4 versions of jquery.js. This is a desastre, because the component is loading jquery + jquery plugin, then jquery is reload so the jquery plugins are lost.

What is the best to do :

- Wait for a possible Joomla 2.5 with jquery support (not change the core of joomla, just add a simple behaviour to prevent two modules using jquery to reload jquery)

- To something like:
load Jquery + jquery plugins then save jquery variable in another variable, then use only this variable.  ?

Thomas

Thomas PAPIN

unread,
Jul 20, 2012, 9:57:23 AM7/20/12
to joomla-de...@googlegroups.com

Alfred Vink

unread,
Jul 20, 2012, 10:55:57 AM7/20/12
to joomla-de...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.

Thomas PAPIN

unread,
Jul 20, 2012, 2:01:24 PM7/20/12
to joomla-de...@googlegroups.com
Will try that

thomas


2012/7/20 Alfred Vink <alf...@alfsoft.com>

Thomas PAPIN

unread,
Jul 22, 2012, 7:15:47 PM7/22/12
to joomla-de...@googlegroups.com
The plugin is nice and several good options.
With the usage of this plugin, the problem is solved.

The only problem (which is not a problem of this plugin) is that we are doing some processing just of course of "Joomla Framework".
The plugin parses the page to find the jquery declaratiion and remove them. This processing is an overhead, necessary because of the not support of jquery in joomla framework.

We include jquery 1 time, then we include jquery a second time then we remove 1 jquery. Seems that something is not optimized here.

What I don't understand is why Joomla Core Team to not add a Jquery Behaviour like Mootools to load JQuery lib, so if several modules are using jquery only 1 is loaded.
If the problem is "several version jquery which one ?", like the jquery easy plugin, you can have a system to only load the max level of Jquery version requires.
Maybe this is not perfect, maybe there are lot of others solution.. But it's always better than no solution at all for 2.5 and the answer (jquery will be part of Joomla 3.0), what about 2.5 support ?

Thomas






2012/7/20 Alfred Vink <alf...@alfsoft.com>

Thomas PAPIN

unread,
Jul 22, 2012, 8:06:09 PM7/22/12
to joomla-de...@googlegroups.com
Oh I finally found information

For reference:

https://github.com/joomla/joomla-platform/pull/1359

Thomas



2012/7/23 Thomas PAPIN <thomas...@gmail.com>

Rouven Weßling

unread,
Jul 23, 2012, 9:38:11 AM7/23/12
to joomla-de...@googlegroups.com

On 23.07.2012, at 01:15, Thomas PAPIN wrote:

What I don't understand is why Joomla Core Team to not add a Jquery Behaviour like Mootools to load JQuery lib, so if several modules are using jquery only 1 is loaded.

Because like you no one has written a set of jQuery behaviors. Not even as an extension.

Rouven

Thomas PAPIN

unread,
Jul 23, 2012, 10:43:05 AM7/23/12
to joomla-de...@googlegroups.com
It's "quite" wrong.

1) There are trace of proposal (one by beat at least) several months ago. : https://github.com/joomla/joomla-platform/pull/736

But you are right, I will check in details Beat proposal and the current proposal for the new framework version and see if we can create a plugin for 2.5 and wait not 1.5 :)

Thomas


2012/7/23 Rouven Weßling <m...@rouvenwessling.de>

--

Rouven Weßling

unread,
Jul 23, 2012, 10:47:09 AM7/23/12
to joomla-de...@googlegroups.com

On 23.07.2012, at 16:43, Thomas PAPIN wrote:

It's "quite" wrong.

1) There are trace of proposal (one by beat at least) several months ago. : https://github.com/joomla/joomla-platform/pull/736

But you are right, I will check in details Beat proposal and the current proposal for the new framework version and see if we can create a plugin for 2.5 and wait not 1.5 :)

That's not a complete set of behaviors, that's just jQuery.

Rouven

Thomas PAPIN

unread,
Jul 23, 2012, 4:50:26 PM7/23/12
to joomla-de...@googlegroups.com
I am not sure to understand your last mail:
the goal is to create a unique jquery behaviour that can load several versions of jQuery.

The beat's solution is doing that.

Thomas


2012/7/23 Rouven Weßling <m...@rouvenwessling.de>

--

Rouven Weßling

unread,
Jul 23, 2012, 4:53:55 PM7/23/12
to joomla-de...@googlegroups.com

On 23.07.2012, at 22:50, Thomas PAPIN wrote:

> I am not sure to understand your last mail:
> the goal is to create a unique jquery behaviour that can load several versions of jQuery.
>
> The beat's solution is doing that.

The jQuery behavior is only half the rent - we need jQuery versions of all the other behaviors or at least those frequently used on the site otherwise you just end up loading both frameworks.

Rouven
Reply all
Reply to author
Forward
0 new messages