when we dynamically load the select options, the bootstrap-select would not mapping it, so we need reinit it.
for example:
$("#goodsNames").selectpicker({}); //初始化 vars = ""; vartimeOut = ""; $(".input-block-level").bind("propertychange input",function(event){ //添加input框事件 s = $(this).val(); clearTimeout(timeOut); timeOut = setTimeout(function(){ //设置延后ajax请求 vartempAjax = ""; $.ajax({ type : 'GET', url : '', dateType : 'json', data : "goodsName="+s, success:function(msg){ $.each(msg,function(i,n){ tempAjax += "<option value='"+n.id+","+n.name+","+n.goodsUnit+","+n.sellReason+","+n.goodsPrice+"'>"+n.name+"</option>"; }); $("#goodsNames").empty(); $("#goodsNames").append(tempAjax); //更新内容刷新到相应的位置 $('#goodsNames').selectpicker('render'); $('#goodsNames').selectpicker('refresh'); } }) },700); })