Bootstrap select 多选给初始值

HTML




JS

初始化:
$(function (){
	//主解析担当
  	var mainAnaylisBear = getJsonArray("","<%=request.getContextPath()%>/other/common/combobox.do?method=comboboxJson&type=getGroupUsersByGroupId&parentCode=新车型不良录入解析担当群组");
  	$("#mainAnaylisBear").empty();
  	$.each(mainAnaylisBear,function(index,item){
  		var tepm = '';
  		$(tepm).appendTo($("#mainAnaylisBear"));
  	});
  	$("#mainAnaylisBear").selectpicker('refresh');
	
	//辅解析担当
  	var anaylisBear = getJsonArray("","<%=request.getContextPath()%>/other/common/combobox.do?method=comboboxJson&type=getGroupUsersByGroupId&parentCode=新车型不良录入解析担当群组");
  	$("#anaylisBear").empty();
  	$.each(anaylisBear,function(index,item){
  		var tepm = '';
  		$(tepm).appendTo($("#anaylisBear"));
  	});
  	$("#anaylisBear").selectpicker('refresh');
});

赋值

//赋单个默认选中
$("#mainAnaylisBear").val(param1);
$('#mainAnaylisBear').selectpicker('refresh');//最后重新刷新bootstrap-select的样式 这句很重要,不加不行

//赋多个默认选中:var param2="p1,p2,p3";
$("#anaylisBear").val(param2.anaylisBears.split(',')); 
$('#anaylisBear').selectpicker('refresh');//最后重新刷新bootstrap-select的样式 这句很重要,不加不行

效果:
Bootstrap select 多选给初始值_第1张图片

你可能感兴趣的:(Bootstrap,Bootstrap)