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

112
Views
select2 agrega clases personalizadas usando processResults

Solía agregar clases personalizadas y usarlas para completar una entrada de acuerdo con la selección, ya que lo hice directamente en la vista

ejemplo:

 <option value="290044" data-nombre="xxxx" data-select2-id="20">0931105/Diego Suarez</option>

pero como tenia que traer mas de 70000 registros lo hago ahora del lado del servidor y no se como agregar las clases personalizadas que quiero que aparezcan me aparece asi automaticamente

ejemplo

 <option value="290044" (here i want to add my custom class) data-select2-id="20">09311055/Diego Suarez</option>

adjunto el codigo completo

 $(document).ready(function () { $("#cliente").select2({ language: "es", minimumInputLength: 2, ajax: { url: "/Clientes/jsonclientes", dataType: "json", delay: 250, processResults: function (data) { return { results: $.map(data, function (item) { return { text: item.NIF20 + "/" + item.NOMBRECLIENTE, id: item.CODCLIENTE, }; }), }; }, cache: true, }, }); $("#cliente").change(function () { let selected = $(this).find("option:selected"); direccion = selected.data("direccion"); $("#direccione").val(direccion); }); })
about 4 years ago · Juan Pablo Isaza
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!