I am using Semantic UI 2.0 and trying to use data returned from its API to build the options inside my dropdown.
For the dropdown itself, I am using a code that is pratically the same as this code shown in Semantic UI's documentation:
<div class="ui search selection dropdown select-city">
<input type="hidden" name="city">
<i class="dropdown icon"></i>
<div class="default text">Select City</div>
</div>
I have a service that returns json-formatted cities, then Semantic UI shows in the console that the result was successful with all 261 cities:
"Using specified url" ["/cities/"] 1648
"Querying URL" ["/cities/"] 0
"Sending request" [undefined, "get"] 0
"Successful API Response" [Object { success=true, results=[261]}]
The /cities endpoint return a json formatted as:
{"success":true,"results":[{"description":"Opole","data-value":1},{"description":"Wrocław","data-value":2},{"description":"Warszawa","data-value":3},{"description":"Budapest","data-value":4},{"description":"Köln","data-value":5}, ...]}
It looks like that Semantic UI does not directly understand the format of the json.
I've tried many formats of json attributes, even tried to change a bit the html. For instance, tried to add an empty <div class="menu"> in the bottom of the select, hoping that Semantic UI would fill it in, e.g.,:
<div class="ui search selection dropdown select-city">
<input type="hidden" name="city">
<i class="dropdown icon"></i>
<div class="default text">Select City</div>
<div class="menu"></div>
</div>
I am trying to match the format of the attributes with the ones from the example, e.g., using "data-value" attribute.
But it did not work either, I've seen Semantic UI checks for that in the source code, so it does not make any difference. At the end, my problem persists and no items are inserted into the dropdown selection.