diff options
| author | Adam Johnson <me@adamj.eu> | 2021-06-23 05:08:10 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-23 06:08:10 +0200 |
| commit | d54059ebce8af9c666fd982942600b641fac86a2 (patch) | |
| tree | 1f589afcb844892dcd679c2d1700a0e967c1445d | |
| parent | bbb3965826c91406b94b819af7315ea1d39ec217 (diff) | |
Removed options parameter from djangoAdminSelect2.
It seems this parameter has never been used internally, so to avoid
exposing a large surface area in the admin, remove it. As discussed in:
https://groups.google.com/g/django-developers/c/G-fDkNxhxsE/m/--RtGwmtAQAJ
| -rw-r--r-- | django/contrib/admin/static/admin/js/autocomplete.js | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/django/contrib/admin/static/admin/js/autocomplete.js b/django/contrib/admin/static/admin/js/autocomplete.js index c55eee1fa6..6095abe233 100644 --- a/django/contrib/admin/static/admin/js/autocomplete.js +++ b/django/contrib/admin/static/admin/js/autocomplete.js @@ -1,28 +1,22 @@ 'use strict'; { const $ = django.jQuery; - const init = function($element, options) { - const settings = $.extend({ - ajax: { - data: function(params) { - return { - term: params.term, - page: params.page, - app_label: $element.data('app-label'), - model_name: $element.data('model-name'), - field_name: $element.data('field-name') - }; - } - } - }, options); - $element.select2(settings); - }; - $.fn.djangoAdminSelect2 = function(options) { - const settings = $.extend({}, options); + $.fn.djangoAdminSelect2 = function() { $.each(this, function(i, element) { - const $element = $(element); - init($element, settings); + $(element).select2({ + ajax: { + data: (params) => { + return { + term: params.term, + page: params.page, + app_label: element.dataset.appLabel, + model_name: element.dataset.modelName, + field_name: element.dataset.fieldName + }; + } + } + }); }); return this; }; |
