Files
ihrm/static/admin/js/autocomplete.js
Nikhil Ravi Cybrosys 9d0d7a2230 [UPDT]summer note in recruitment (#9)
* [UPDT]candidate update stage

* [FIX]typo in notification - email sent

* [UPDT]recruitment updates

* [UPDT]onboarding updates

* [UPDT]attendance updates

* [UPDT]employee updates

* [UPDT]updated static files for summernote

---------

Co-authored-by: NIKHIL RAVI <nikhil.ravi10@gmail.com>
2023-06-06 12:27:41 +05:30

34 lines
1.0 KiB
JavaScript

'use strict';
{
const $ = django.jQuery;
$.fn.djangoAdminSelect2 = function() {
$.each(this, function(i, element) {
$(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;
};
$(function() {
// Initialize all autocomplete widgets except the one in the template
// form used when a new formset is added.
$('.admin-autocomplete').not('[name*=__prefix__]').djangoAdminSelect2();
});
document.addEventListener('formset:added', (event) => {
$(event.target).find('.admin-autocomplete').djangoAdminSelect2();
});
}