Usé Select2.Js para el menú desplegable. Pero el valor no se muestra en el menú desplegable sin ingresar un valor o palabra. Cada vez que tengo que insertar una palabra para obtener resultados.
Traté de hacer minimumInputLength: 0 pero no funciona. Solo necesito un menú desplegable simple.
Aquí está mi código
$("#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 });