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

226
Vistas
Select2.Js Doesn't Show Dropdown Without Entering Values In Text Filed

I used Select2.Js for dropdown menu. But the value isn't show in Dropdown without entering one value or word. Everytime I have to insert one word to get results.

I tried to make minimumInputLength: 0 But doesn't work. I need only Simple Dropdown Menu.

https://i.stack.imgur.com/YNrl5.png

Here is My Code

        $("#stores").select2({
            ajax: {
                url: storeSearchUrl,
                dataType: 'json',
                type: 'POST',
                data: function (params) {
                    return {
                        searchText: params.term
                    };
                },
                processResults: function (data, params) {
                    
                    if (data.redirect) {
                        window.location.href = data.redirect;
                    } else {
                        if (data.error) {
                            app.notification('error', data.error);
                        } else {
                            return {
                                results: $.map(data, function (item) {
                                    if(labaccess != null && labaccess != "" && labaccess != "[]"){
                                        if(labaccess.includes(item.id)){
                                            return {
                                                text: item.name,
                                                id: item.id,
                                                term: params.term
                                            }
                                        }
                                    }
                                    else{
                                        return {
                                            text: item.name,
                                            id: item.id,
                                            term: params.term
                                        }
                                    }
                                })
                            };
                        }
                    }
                },
                cache: false
            },
            templateResult: function (item) {
                if (item.loading) {
                    return item.text;
                }
                return app.markMatch(item.text, item.term);
            },
            minimumInputLength: 0
        });
        
about 4 years ago · Santiago Trujillo
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