Files
opensem/resources/views/load/form/select2.blade.php

51 lines
1.3 KiB
PHP

@if(!defined('LOAD_SELECT2'))
@push('scripts')
<script src="/assets/plugins/select2/js/select2.full.min.js"></script>
<script src="/assets/plugins/select2/js/i18n/{{ App::getLocale() }}.js"></script>
<script>
function initSelect2(sel, parent) {
console.log('initSelect2');
// $.fn.modal.Constructor.prototype.enforceFocus = function() {};
var selector = (typeof(sel) == 'undefined') ? '.select2' : sel;
if (typeof(parent) == 'undefined') {
$(selector).select2({
placeholder: "{{ __('select_a_value') }}",
allowClear: false,
width: {
value: '100%'
}
});
} else {
$(selector).select2({
placeholder: "{{ __('select_a_value') }}",
allowClear: true,
dropdownParent: $(parent),
width: {
value: '100%'
}
});
}
/*
$(selector).on('select2:open',(e) => {
let t = $(e.target);
console.log(t);
if (t && t.length) {
let id = t[0].id || t[0].name;
console.log(id);
let item = $(`input[aria-controls*='${id}']`);
console.log(item);
return item ? item.focus() : false;
}
});
*/
}
</script>
@endpush
@push('css')
<link rel="stylesheet" href="/assets/plugins/select2/css/select2.min.css">
@endpush
@php(define('LOAD_SELECT2', true))
@endif