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

224
Views
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
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!