[wp-trac] [WordPress Trac] #22896: Prevent plugins from overriding jQuery in the admin
WordPress Trac
noreply at wordpress.org
Fri Jan 25 00:49:56 UTC 2013
#22896: Prevent plugins from overriding jQuery in the admin
------------------------------------+------------------
Reporter: nacin | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 3.6
Component: External Libraries | Version:
Severity: normal | Resolution:
Keywords: dev-feedback has-patch |
------------------------------------+------------------
Comment (by auniquename):
Replying to [comment:30 azaozz]:
> With jQuery there is a better way to do this: let the WordPress jQuery
load first, then load your desired version in the footer or right before
it's needed, load jQuery UI or any other plugins you want to use with the
different version and do:
>
> {{{
> var myjq = jQuery.noConflict(true);
> }}}
>
> Ref: http://api.jquery.com/jQuery.noConflict/#example-4
>
> Then in your scripts you can use the version you want:
>
> {{{
> (function($){
> // your code here uses the alternative jQuery version
> }(myjq));
>
> (function($){
> // this uses the standard jQuery version
> }(jQuery));
> }}}
>
>
> This is '''the proper way''' to load several versions of jQuery and have
them all work and (of course) doesn't affect or break anything in
WordPress.
I of course tried '''exactly that''' first (see long boring story above).
Like so:
{{{
/* included minified jQuery */
var mypluginjq = jQuery.noConflict();
/* included minified jQuery UI */
/* included minified Iris */
mypluginjq(document).ready(function($) {
/* My Plugin jQuery stuff */
});
}}}
As instructed here:
http://docs.jquery.com/Using_jQuery_with_Other_Libraries
and here:
http://docs.jquery.com/Core/jQuery.noConflict
''It did not work.'' When I called a jQuery version check outside and
within the scoped functions it reported the same version everywhere - the
last one loaded. And when called from other plugins, all reported the same
version of jQuery, the last one loaded.
The difference being perhaps that I am mostly trying to use fully scoped
jQuery UI themes and I see detail here that most do not or perhaps never
will.
My guess is that no one has ever tested enough functionality to see a
difference. Or actually made version calls.
Maybe I screwed something up, but I don't think so. I'll try a very simple
test page to see...
--
Ticket URL: <http://core.trac.wordpress.org/ticket/22896#comment:33>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list