I have a multi select list
<div id="statusWrapper" class="row" style="left:2px">
@Html.LabelFor(model => model.Countries, htmlAttributes: new { @class = "col-sm-4 label-box required" })
<div class="col-md-6 input-group" style="left:2px; width: 47%;">
@Html.ListBoxFor(model => model.SelectedCountryIds, (MultiSelectList)Model.Countries, new { @class = "multiselect form-control", multiple = "multiple", id = "cbJT" })
</div>
</div>
<div class="row" style="padding:2px">
@Html.Label("City", new { @class = "col-sm-4 label-box required" })
<div class="col-sm-6 value-box" style="padding-left:2px; padding-top: 2px;">
@Html.DropDownListFor(model => model.CityId, Enumerable.Empty<SelectListItem>(), "Select", new { @class = "combobox form-control"})
@Html.ValidationMessageFor(x => x.CityId)
</div>
</div>
The first is a multiselect dropdown that gets populated on page load. Second drop down is dynamically populated whenever there is a selection (or deselection) in the previous list.
$('#cbJT').on('change', function (e) {
$('#CityId').empty();
$.each(this.selectedOptions, function (id, opt) {
$('<option>').val(opt.value).text(opt.text).appendTo('#CityId');
});
);
This successfully appends to the select tag, but drop down list is unable to expand, like it is empty, even though after a few selections, it holds values of a few countries.