Javascript 动态MVC多段下拉列表

Javascript 动态MVC多段下拉列表,javascript,jquery,asp.net-mvc,bootstrap-multiselect,Javascript,Jquery,Asp.net Mvc,Bootstrap Multiselect,我正在尝试创建一个动态的多选下拉列表。下面的代码不起作用 <div class="form-group"> @Html.Label("Solutions", htmlAttributes: new { @class = "control-label col-md-4" }) <div class="col-md-8"> @Html.DropDownListFor(model => m

我正在尝试创建一个动态的多选下拉列表。下面的代码不起作用

  <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>

@Label(“Solutions”,htmlAttributes:new{@class=“controllabel col-md-4”})
@Html.DropDownListFor(model=>model.SolutionList,new SelectList(new List(),“Value”,“Text”),new{multiple=“true”,“@class=”表单控制列表组活动颜色”,Style=“width:100%!important”,onchange=“ongetsolutionchange(this)”)
@Html.ValidationMessageFor(model=>model.SolutionList,“,new{@class=“text danger”})
var solutionOptions=“”

jQuery(结果)。每个(函数(){
solutionOptions+=“”+此.Text+“”;
});       
目标。追加(解决方案选项);
target.multiselect('rebuild')

这解决了我的问题:

jQuery("#SolutionList").multiselect('destroy');
jQuery("#SolutionList").multiselect();

    jQuery(result).each(function () {
       $("#SolutionList").append('<option value="' + this.Value + '">' + this.Text + '</option>').multiselect('rebuild');
    });    
jQuery(#SolutionList”).multiselect('destroy');
jQuery(“#解决方案列表”).multiselect();
jQuery(结果).each(函数)(){
$(“#解决方案列表”).append(''+this.Text+'').multiselect('rebuild');
});    

这解决了我的问题:

jQuery("#SolutionList").multiselect('destroy');
jQuery("#SolutionList").multiselect();

    jQuery(result).each(function () {
       $("#SolutionList").append('<option value="' + this.Value + '">' + this.Text + '</option>').multiselect('rebuild');
    });    
jQuery(#SolutionList”).multiselect('destroy');
jQuery(“#解决方案列表”).multiselect();
jQuery(结果).each(函数)(){
$(“#解决方案列表”).append(''+this.Text+'').multiselect('rebuild');
});    

在下面的链接中,我将解释如何使用引导多重选择


在下面的链接中,我将解释如何使用引导多重选择


谢谢。我要看看,谢谢。我去看看