Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

124
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda