Opened 8 years ago

Closed 8 years ago

#26885 closed Bug (invalid)

django admin jquery initial changed in 1.9+

Reported by: WANG WENPEI Owned by: nobody
Component: contrib.admin Version: 1.9
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi,all:

Does somebody can explain why we change jquery.init.js file in admin module ?

in current code, this style cause some scope issue.
we can't get jQuery,$ in global.

/*global django:true, jQuery:false*/
/* Puts the included jQuery into our own namespace using noConflict and passing
 * it 'true'. This ensures that the included jQuery doesn't pollute the global
 * namespace (i.e. this preserves pre-existing values for both window.$ and
 * window.jQuery).
 */
var django = django || {};
django.jQuery = jQuery.noConflict(true);

in 1.8 release package . the code is

var django = django || {};
django.jQuery = jQuery;

var yl = yl || {};
yl.jQuery = django.jQuery;

// this file also prevents django.jQuery.noConflict
// there's got to be a better way ...

I don't think this is a better improve .

we have so many plugins depend on global jQuery or $ ! we can't use them anymore,we have to add custom jQuery lib or change code to local scope.

I submit a PR , if you agree with me, please confirm it.

Change History (3)

comment:2 by Tim Graham, 8 years ago

I'm confused by the report. jquery.init.js seems to be identical in Django 1.8 and 1.9:

var django = django || {};
django.jQuery = jQuery.noConflict(true);

The rationale for namespacing is described in the documentation.

comment:3 by Claude Paroz, 8 years ago

Resolution: invalid
Status: newclosed

Like Tim said, nothing changed at this level in Django 1.9.

Note: See TracTickets for help on using tickets.
Back to Top