javascript - Selectize.js update option label from ajax -
i have drop down select field rendered server, , contains selected option only, value no text.
<select name="countrycode"> <option value="us" selected="selected"></option> </select>
later, initialize selectize
$('[name=countrycode]').selectize({ load: function(query, callback) { $.ajax({ url: `countrycode.php?q=${query}` }).done((data, textstatus, jqxhr) => callback(data.countrycodes)); } });
where countrycode.php
returns following json
{ countrycodes: [{ text: 'united states', value: 'us' }, ... }
is there way update text label of rendered option?
Comments
Post a Comment