Skip to content

Commit

Permalink
Fixed a bug in the way jquery.init.js was being used.
Browse files Browse the repository at this point in the history
  • Loading branch information
coredumperror authored and jpic committed Sep 13, 2018
1 parent eb343e8 commit 1def59f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
8 changes: 0 additions & 8 deletions src/dal/static/admin/js/jquery.init.js

This file was deleted.

23 changes: 17 additions & 6 deletions src/dal/static/autocomplete_light/jquery.init.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
var yl = yl || {};
// Directly above this file, we included the jQuery provided by django. That
// means it set itself to window.$ and window.jQuery, and stored away any
// existing jQuery that may have been installed previously. Calling
// jQuery.noConflict(true) will remove OUR copy of jQuery from the global
// namespace and restore the original values of window.$ and window.jQuery.
// This is necessary so that code which uses a version of jQuery that may
// have been installed up-page gets the version it expects.
yl.jQuery = jQuery.noConflict(true);

if (yl.jQuery === undefined) {
/* If the user has included another copy of jQuery use that, even in the admin */
if (typeof $ !== 'undefined')
yl.jQuery = $;
else if ((typeof django !== 'undefined') && (typeof django.jQuery !== 'undefined'))
yl.jQuery = django.jQuery;
// Here, we set up django.jQuery, instead of letting admin/js/jquery.init.js
// do it. This is necessary because it ALSO calls jQuery.noConflict(true).
// It we let it do that, it would break any code further down the page that
// expects window.$ and window.jQuery to be defined.
var django = django || {};
if (typeof django.jQuery === 'undefined') {
// If django.jQuery is not yet defined, we need to define it so that
// admin/js/autocomplete.js (which we include with our widget) can run.
django.jQuery = yl.jQuery;
}
1 change: 0 additions & 1 deletion src/dal_select2/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def media(self):
'admin/js/vendor/jquery/jquery%s.js' % extra,
'admin/js/vendor/select2/select2.full%s.js' % extra,
) + i18n_file + (
'admin/js/jquery.init.js',
'autocomplete_light/jquery.init.js',
'autocomplete_light/autocomplete.init.js',
'admin/js/autocomplete.js',
Expand Down

0 comments on commit 1def59f

Please sign in to comment.