Fix select2 re-renders

This commit is contained in:
Marcus Moore 2024-05-30 16:20:04 -07:00
parent f03249898a
commit 2eaac3d381
No known key found for this signature in database
2 changed files with 4 additions and 3 deletions

View file

@ -644,8 +644,8 @@ document.addEventListener('livewire:init', () => {
Livewire.find(target.data('livewire-component')).set(event.target.name, this.options[this.selectedIndex].value)
});
Livewire.hook('commit', function ({succeed}) {
succeed(({snapshot, effect}) => {
Livewire.hook('request', ({succeed}) => {
succeed(() => {
queueMicrotask(() => {
$('.livewire-select2').select2();
});

View file

@ -153,6 +153,7 @@
<div class="col-md-9 col-xs-12" wire:ignore>
{{ Form::select('activeFile.import_type', $importTypes, $activeFile->import_type, [
'id' => 'import_type',
'class' => 'livewire-select2',
'style' => 'min-width: 350px',
'data-placeholder' => trans('general.select_var', ['thing' => trans('general.import_type')]),
'placeholder' => '', //needed so that the form-helper will put an empty option first
@ -227,7 +228,7 @@
{{ Form::select('field_map.'.$index, $columnOptions[$activeFile->import_type], @$field_map[$index],
[
'class' => 'mappings',
'class' => 'mappings livewire-select2',
'placeholder' => trans('general.importer.do_not_import'),
'style' => 'min-width: 100%',
'data-livewire-component' => $this->getId()