mirror of
https://github.com/a2nt/webpack-bootstrap-ui-kit.git
synced 2024-10-22 11:05:45 +02:00
IMPR: old js select2 AJAX
This commit is contained in:
parent
307f250c08
commit
fcc6345dc6
@ -30,8 +30,28 @@ const FormSelect2 = (($) => {
|
|||||||
.find('select:not([readonly])')
|
.find('select:not([readonly])')
|
||||||
.not('.no-select2')
|
.not('.no-select2')
|
||||||
|
|
||||||
$selectFields.each((i, el) => {
|
$selectFields.each((i, eli) => {
|
||||||
$(el).select2()
|
const $eli = $(eli);
|
||||||
|
|
||||||
|
if ($eli.hasClass('js-data-ajax')) {
|
||||||
|
console.log($eli.data('source'));
|
||||||
|
$eli.select2({
|
||||||
|
ajax: {
|
||||||
|
url: $eli.data('source'),
|
||||||
|
dataType: 'json',
|
||||||
|
data: function (params) {
|
||||||
|
const query = {
|
||||||
|
search: params.term,
|
||||||
|
page: params.page || 1
|
||||||
|
}
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$eli.select2()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
$el.addClass(`${NAME}-active`)
|
$el.addClass(`${NAME}-active`)
|
||||||
|
Loading…
Reference in New Issue
Block a user