欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

bootstrap-select使用

程序员文章站 2022-04-10 16:12:20
...
bootstrap-select没提供动态请求数据的方法,解决动态添加的问题

下载,例子,文档地址
http://silviomoreto.github.io/bootstrap-select/

$("#goodsNames").selectpicker({});  //初始化
   var s = "";
   var timeOut = "";
   $(".input-block-level").bind("propertychange input",function(event){   //添加input框事件
       s = $(this).val();
       clearTimeout(timeOut);
       timeOut = setTimeout(function(){   //设置延后ajax请求
           var tempAjax = "";
           $.ajax({
                 type : 'GET',
                 url : '',
                 dateType : 'json',
                 data : "goodsName="+s,
                 success: function(msg){
                     $.each(msg,function(i,n){
                        tempAjax += "";
                     });
                     $("#goodsNames").empty();
                     $("#goodsNames").append(tempAjax);    
                                         //更新内容刷新到相应的位置
                     $('#goodsNames').selectpicker('render');
                     $('#goodsNames').selectpicker('refresh');
                 }
            })
        },700);
        
   })

bootstrap-select使用

bootstrap-select使用

相关标签: bootstrap-select使用