Clicking Twice in Select to Get Option List
- <select id="selectid">
- <option></option>
- </select>
- var valArray = data.valarray; // data is coming in correctly from an ajax call
$('#selectid).children('option:not(:first)').remove();
- // selfld are defined correctly
for (var i = 0; i <= valArray.length - 1; i++) {
$('#selectid).append('<option value="' + valArray[i][selfld] + '">' + valArray[i][selfld] + '</option>');
}
When I view the select list and click on it, the above code runs inside of an on focus and the new option values are coming in correctly, but the selection list is NOT extended. I have to click again to get the dynamically-generated option list. Is there a way to show the option list right after they are generated ?