On Fri, Oct 22, 2010 at 10:09 AM, tyrion-mx <tyrion...
> 1) contrib.admin places jQuery in its own namespace `django.jQuery`.
> In this way other jQuery instances should not conflict with it.
> 2) It also removes the dollar sign AND the `jQuery` object from the
> global scope.
> *I think* removing the `jQuery` object is not necessary because it
> *should* not conflict with any other jQuery instance.
I don't think of it as "removing" the object... it's more of putting
back what was there before Django's jQuery initialization happened.
> If an admin customization that uses jQuery is loaded, as it should,
> override the django's one, and django will still be able to use jQuery
> with `django.jQuery`.
on whether they should extend or use window.jQuery or django.jQuery.
> If an admin customization is loaded before the contrib.admin's
> the global scope. That's because jQuery.noConflict(true) removes the
> jQuery object from the global scope, but doesn't prevent it to be
> created and attached to window (thus overwriting the user's one).
I believe this isn't quite right. If I load my own jQuery (and
plugins that possibly may extend that specific jQuery object) prior to
admin loading its jQuery, the admin's jQuery will move the existing
window.jQuery to a temp variable, load itself, then put the original
object back. Thus we have the original jQuery unaffected and lives in
window.jQuery (along with all its extensions or different version),
and Django's jQuery lives at django.jQuery.
With `jQuery.noConflict(true)` we're not overwriting the `$` or
`jQuery` global objects at all, and keeping our own jQuery self
> Moreover I wont' be able to use any jQuery plugin (that directly
> references `jQuery`) in the admin (without hacking with
> ModelAdmin._media), because the `jQuery` object does not exist. I am
> forced to include jquery twice ...
This is a good point...
I suppose one could assign Django's jQuery object to the global jQuery
object? I haven't tried it but this might avoid needing to include 2
copies of jQuery if you're ok with the version Django bundles: