Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

116
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!