Skip to content

Commit bdacec2

Browse files
committed
fixup! fix: use Django's vendored select2 js lib
1 parent 4863703 commit bdacec2

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed
Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
{% load i18n static %}
22

33
<script type="text/javascript">
4-
// globals
5-
var _af_handlers = window._af_handlers || null;
6-
var ADVANCED_FILTER_CHOICES_LOOKUP_URL = "{% url 'afilters_get_field_choices' %}";
4+
'use strict';
5+
{
6+
const $ = django.jQuery;
7+
// globals
8+
var _af_handlers = window._af_handlers || null;
9+
var ADVANCED_FILTER_CHOICES_LOOKUP_URL = "{% url 'afilters_get_field_choices' %}";
710

8-
// common advanced filter tabular form initialization
9-
(function($) {
10-
$("#{{ formset.prefix }}-group > tbody > tr")
11-
.tabularFormset({
11+
// common advanced filter tabular form initialization
12+
$(function() {
13+
const selector = "#{{ formset.prefix }}-group tbody:first > tr";
14+
const options = {
1215
prefix: "{{ formset.prefix }}",
1316
adminStaticPrefix: '{% static "admin/" %}',
1417
addText: "{% trans "Add another filter" %}",
@@ -22,6 +25,8 @@
2225
preAdded: function(row) {
2326
if (_af_handlers) _af_handlers.destroy(); // cleanup
2427
}
28+
}
29+
$(selector).tabularFormset(selector, options);
2530
});
26-
})(django.jQuery);
27-
</script>
31+
}
32+
</script>

0 commit comments

Comments
 (0)