Forums

autocomplete dropdown order messed up

emmexx 31 Aug, 2018
I added a dropdown to a form and and created an event in the connection to retrieve some data.
The event retrieves the data in alphabetical order:
{"76012":"Bella (Potenza)","13250":"Bellagio (Como)","97008":"Bellano 
(Lecco)","67006":"Bellante (Teramo)","99001":"Bellaria-Igea Marina 
(Rimini)","58012":"Bellegra (Roma)","4017":"Bellino 
(Cuneo)","15016":"Bellinzago Lombardo (Milano)","3016":"Bellinzago 
Novarese (Novara)","65158":"Bellizzi (Salerno)","61007":"Bellona 
(Caserta)","65015":"Bellosguardo (Salerno)","25006":"Belluno 
(Belluno)","108006":"Bellusco (Monza e della Brianza)"}
But the elements are in a different order in the popup window displayed to select some element:
<div class="menu transition visible" tabindex="-1" style="display: block ! important;">
<div class="item selected" data-value="3016">Bellinzago Novarese (Novara)</div>
<div class="item" data-value="4017">Bellino (Cuneo)</div>
<div class="item" data-value="13250">Bellagio (Como)</div>
<div class="item" data-value="15016">Bellinzago Lombardo (Milano)</div>
<div class="item" data-value="25006">Belluno (Belluno)</div>
<div class="item" data-value="58012">Bellegra (Roma)</div>
<div class="item" data-value="61007">Bellona (Caserta)</div>
<div class="item" data-value="65015">Bellosguardo (Salerno)</div>
<div class="item" data-value="65158">Bellizzi (Salerno)</div>
<div class="item" data-value="67006">Bellante (Teramo)</div>
<div class="item" data-value="76012">Bella (Potenza)</div>
<div class="item" data-value="97008">Bellano (Lecco)</div>
<div class="item" data-value="99001">Bellaria-Igea Marina (Rimini)</div>
<div class="item" data-value="108006">Bellusco (Monza e della Brianza)</div>
</div>
The order used seems to be that of the data-value attribute.
json_encode adds quotes to the index of the array elements.

Shouldn't the elements be ordered by label and not value of the elements?
Is there a way to accomplish that?

Thank you
maxx
This topic is locked and no more replies can be posted.