27 lines
1.0 KiB
PHP
27 lines
1.0 KiB
PHP
@if (!defined('LOAD_AUTOCOMPLETE'))
|
|
@push('js')
|
|
<script src="{{ asset('/assets/plugins/autocomplete/bootstrap-autocomplete.min.js') }}"></script>
|
|
<script>
|
|
function initAutocomplete(sel, callback) {
|
|
var selector = (typeof(sel) == 'undefined') ? '.autocomplete' : sel;
|
|
$(selector).autoComplete({
|
|
noResultsText: ''
|
|
});
|
|
|
|
$(selector).on('autocomplete.select', function(evt, item) {
|
|
var field = $(this).data('field');
|
|
var id = item.value;
|
|
$('#' + field).val(id);
|
|
|
|
if (typeof callback === 'function') {
|
|
callback.call(this, item, evt);
|
|
} else if (typeof callback === 'string' && callback.length && typeof window[callback] === 'function') {
|
|
window[callback].call(this, item, evt);
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
@endpush
|
|
@php(define('LOAD_AUTOCOMPLETE', true))
|
|
@endif
|