Override Core Jquery Version With Block

Permalink
I am working on a block for the marketplace that is a jquery plugin. However, I discovered that it requires at least jquery 1.9 or newer to work! The problem is that the core Concrete jquery version is only 1.7.1 (or 1.7.2 in latest stable version).

Is there a way to safely use the latest version of jquery (1.9.x) so that it doesn't cause any conflicts? How would I do this as part of a package?

PineCreativeLabs
 
JohntheFish replied on at Permalink Reply
JohntheFish
The only way to do this locally to your block would be to put it all in an iframe, hence ringfenced from any other js scope.

Any jquery not local to the block would likely result in collisions or incompatibilities.

I put together a pull request aimed at 5.6 (that wasn't accepted) that would allow a global override of any asset through a site constant. I used it on some experimental sites without issue with jquery 1.8. You can find it on github, but it would never be approved with a marketplace addon.
DennisJamin replied on at Permalink Reply
As this is still the first result on Google after searching for a sollution for the same problem, I descided to share the solution I am using for a block that's dependent on the latest jQuery version as well.

For now the only safe way to utilize the latest jQuery (and jQuery UI) version seems to be to include a noConflict version within your block, theme or site. Include the latest versions by creating a file with the jQuery source, optionally jQuery UI source and call it using noConflict;

<jquery source>
<jquery ui source>
var jq1_11_0 = jQuery.noConflict(true);


Passing the 'true' parameter ensures the globally scoped jQuery variable is returned to the first (original C5) version, so C5 will continue to work as it should.
GuillaumeA replied on at Permalink Reply
GuillaumeA
Hello,
I try to setup a carrousel library js but it need the jquery 1.9.1.
So it seem you give a solution... but I don't understand how and where write what your talking about (noConflict thing).
Can you please gice a complete example ?
Thanks for your help
JohntheFish replied on at Permalink Reply
JohntheFish
The noconflict setting is a jQuery option to map jQuery to something other than $
http://api.jquery.com/jquery.noconflict/...

The only way you can do that without risking undesirable side effects is to put the carousel in an iframe.

If you really want to override the core jquery, you will need to override the core php code that actually loads it to map to a different version or to intercept the page rendering and map the html.

Beware that it could break other jQuery code in the core and various addons!!!!

A rejected pull request for asset mapping:
https://github.com/concrete5/concrete5/pull/771...

For intercepting the page rendering, have a look at Miser
http://www.concrete5.org/developers/open-source/...
GuillaumeA replied on at Permalink Reply
GuillaumeA
Thanks for your answer... It seems a bit complicated because the content in the iframe would come form the controller of my block and with content of my concrete5 admin... did you already use this method in this case ?
If yes do you have an example for me ?

Thnaks for your help