how can I set the selected item of a search dropdown (select) form field? I tried it with the following jQuery/JavaScript code:
if (equal == 0) {
$('#sj_company').html($('#sj_company').html() + '<option value="' + key + '" selected="selected">' + data[key] + '</option>');
$('.searchdropdown').dropdown('set selected', data[key]);
} else {
$('#sj_company').html($('#sj_company').html() + '<option value="' + key + '">' + data[key] + '</option>');
}
Edit: The base is the semantic ui frontend framework ;-)
My mistake was: I have initialized the Semantic UI Dropdown before I've loaded the dropdown items via AJAX. The solution: Initialize the Dropdown AFTER the AJAX loading process.