FossilRepo

fossilrepo / assets / admin / js / autocomplete.01591ab27be7.js
Blame History Raw 34 lines
1
'use strict';
2
{
3
const $ = django.jQuery;
4
5
$.fn.djangoAdminSelect2 = function() {
6
$.each(this, function(i, element) {
7
$(element).select2({
8
ajax: {
9
data: (params) => {
10
return {
11
term: params.term,
12
page: params.page,
13
app_label: element.dataset.appLabel,
14
model_name: element.dataset.modelName,
15
field_name: element.dataset.fieldName
16
};
17
}
18
}
19
});
20
});
21
return this;
22
};
23
24
$(function() {
25
// Initialize all autocomplete widgets except the one in the template
26
// form used when a new formset is added.
27
$('.admin-autocomplete').not('[name*=__prefix__]').djangoAdminSelect2();
28
});
29
30
document.addEventListener('formset:added', (event) => {
31
$(event.target).find('.admin-autocomplete').djangoAdminSelect2();
32
});
33
}
34

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button