Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

367
Visualizações
select2 auto clear after submit (Laravel , Livewire)

i have barcode scanner i want whenever submit barcode auto select and after than automatically clear the search box

   <script>
    $(document).ready(function() {
        $('.js-example-basic-single1').select2();
        $('.js-example-basic-single1').select2('open');
        $('.js-example-basic-single1').on('change', function (e) {
            @this.set('item_id', e.target.value);
            $(this).select2('positionDropdown', true);
            $(this).select2("val", "");    
        });
    });
});
</script>
 <select autofocus class="form-control js-example-basic-single1" id="js-example-basic-single1" data-allow-clear="true" wire:submit.prevent="item_id" id="item_id">
<option  value="{{$item_detail->id}}-1">{{$item_detail->item->id}}-{{$item_detail->item->title}}-{{$item_detail->item->barcode}}</option>
</select>```
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

With select2, you need to clear it and then trigger the change. This can be done using the library within your function above like so:

$(this).val(null).trigger('change');

That excellent library has pretty decent docs, including for the above question

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda