bootstrap-select使用注意事项

bootstrap-select,使用多选时注意,

1,初始化多选内容

$("#id").selectpicker("refresh")

$("#id").selectpicker("render")

 

2设置多选款默认内容,

 要设置多选数据的code值,设置name不生效

然后要$("#id").selectpicker("refresh")一下,否则不会更新ui

 

插入元素的时候最好不要在循环里写$("#id").append('')

写成  var html= ""

循环里  html+= ' <option value="'+data[i].code+'">'+data[i].name+'</option> '

循环外

$("#id").append(html)

posted on 2020-11-28 09:47  万能的李大少  阅读(336)  评论(0编辑  收藏  举报