我正在嘗試創建動態多選下拉列表。下面的代碼不起作用動態MVC多部分下拉列表
<div class="form-group">
@Html.Label("Solutions", htmlAttributes: new { @class = "control-label col-md-4" })
<div class="col-md-8">
@Html.DropDownListFor(model => model.SolutionList, new SelectList(new List<SelectListItem>(), "Value", "Text"), new { multiple = "true", @class = "form-control list-group-active-color", Style = "width:100% !important", onchange = "OnGetSolutionsChange(this)" })
@Html.ValidationMessageFor(model => model.SolutionList, "", new { @class = "text-danger" })
</div>
</div>
var solutionOptions =「」;
jQuery(result).each(function() {
solutionOptions += "<label><input type='checkbox' name='categories' value='" + this.Value + "'>" + this.Text + "</input></label>";
});
target.append(solutionOptions);
target.multiselect('rebuild')
[這裏我解釋一下多選舉](HTTP:// stackoverflow.com/questions/43217787/dynamic-mvc-multisect-dropdownlist) –