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

117
Visualizações
Add fixed item and non-removable item to select2?

I have a mail module and I want to add the mentioned (in the photo) email or hr@example.com to be fixed selected and non-removable option in cc in a multi selection select2. How may I achieve this? any idea?

Here is my Blade syntax for selecting cc :

<div class="form-group">
    <label>CC <span class="astirered">*</span></label>
    {!! Form::select('cc[]', $employee_list, $mail_cc_user_id, ['class'=>'form-control select2','multiple']) !!}
    <span class="astirered">{!! $errors->first('cc') !!}</span>
</div>

and this is the script of select 2 :

$('.select2').select2({
    placeholder: "Please select one"
});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I dont think select 2 has a built in way for that, but with some additional JQuery it is possible to hide it. If you look the select box with inspector you will find something like this

<li class="select2-selection__choice" title="mni@email.com" data-select2-id="id">
    <span class="select2-selection__choice__remove" role="presentation">×</span>
    mni@email.com
</li>

You could remove that x by jQuery like this:

$('li.select2-selection__choice[title="mni@email.com"]').find('span.select2-selection__choice__remove').remove();

And then for exmaple you could mark that specific email default selected in the form, then run that jQuery command when document loads.

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