Javascript SelectPicker-如果结果不符合';t通过引导选择进行匹配

Javascript SelectPicker-如果结果不符合';t通过引导选择进行匹配,javascript,jquery,select,search,bootstrap-selectpicker,Javascript,Jquery,Select,Search,Bootstrap Selectpicker,我想默认显示其他,并启用选择。如果我们键入的结果与选项不匹配,则会出现这种情况 $('.selectpicker')。selectpicker({ noneResultsText:“我没有找到任何结果” }); 其他 阿拉巴马州 阿拉斯加州 亚利桑那州 我修改了bootstrap-select.js以适应这种行为 我在搜索事件之后插入了这行代码,这将搜索数据属性中带有“Other”的选项,并将始终显示它 var defaultOption; that.$lis.find('

我想默认显示
其他
,并启用选择。如果我们键入的结果与选项不匹配,则会出现这种情况

$('.selectpicker')。selectpicker({
noneResultsText:“我没有找到任何结果”
});

其他
阿拉巴马州
阿拉斯加州
亚利桑那州

我修改了bootstrap-select.js以适应这种行为

我在搜索事件之后插入了这行代码,这将搜索数据属性中带有“Other”的选项,并将始终显示它

    var defaultOption;

    that.$lis.find('a').each(function(){
      // console.log($(this).data("normalized-text"));

      if($(this).data("normalized-text").indexOf("other") >-1){
        defaultOption = $(this);
      }
    });

    defaultOption.parent().removeClass('hide').show();
我缩小了下面的脚本。请运行代码段

!(一)1}(一)功能i(t)功能i(t)功能i(t)功能i(t)功能i(t)各(t)功能(t)功能i(t)功能(t)返回e.每个([{{{{{{{re:/[[[0:[[[0:[[[0:[0:[[0:[0-\xC0-\x0-\xC0-\xC0-[[[[[[[[[[0-\xC0-\xC0-\xC6][[[[[[[[[[[[[[[[[[[[[[[[0-\xC6]]]][[[[[[6]或...........政府当局当局当局当局当局当局当局当局采用采用采用采用严密严密的使用严格的使用”的使用”使用”的使用”的使用;强强强强强强强;;;i“},{re://[\xD2-\xD6]/g,ch:“O”},{re://[\xF2-\xF6]/g,ch:“O”},{re:/(9-\xDC)c/g,ch:[9-\xDC-\xDC]/g,g,ch:[9-\xDC-\xDC]/g,g,ch:[9-\xDC-\xDC]/g,ch:[9,ch:[9-\xDC:[9-\xDC:[3]g,g,g,c,g,c,c:[3,c:[3-[9-\X7-\X7-\X7-\X7-\XC,c,g,g,g,g,g,c,c,c:[c,,,,[3,c:[7,c:[7,c:[c:[c:[c:[c:[c:[c:[3,[3:[7]g,g:[3:[1:[1:[1:[1:[1:[1]g,g:[1]g,g:[1例如,i=“(?:”+Object.keys(t).join(|)”+”,N=newregexp(i),s=newregexp(i,“g”),o=null==e?”:“+e;返回N.test(o)?o.replace(s,function(e){return t[e]}:o}e.expr[“:”].icontains=function(i,n,s){return t(e(i.text(),s[3]),e.expr[“:”).aicontains=function(i,n,s){return t(e(i.data(“normalizedText”)| | e(i.text(),s[3]);var s=function(t,i,i,n){n&(n.stoppagation(),n(),n.prevent),this=default元素($e),this.$newElement=null,this.$button=null,this.$menu=null,this.$lis=null,this.options=i,null==this.options.title&&(this.options.title=this.$element.attr(“title”)),this.val=s.prototype.val,this.render=s.prototype.render,this.refresh=s.prototype.setStyle=s.prototype.setStyle,this.selectAll=s.prototype.selectAll,this.destroy=s.prototype.remove,this.remove=s.prototype.remove,this.show=s.prototype.show,this.hide=s.prototype.hide,this.init()};函数o(t,i)(o)无效0==t&(t=a)(t=a)(t=a)(t=a)(t=a);var l=t&(t=a);var l=t=a;var l=这个.每个(函数)函数(函数)的var a=e(这个);o=参数,a=t=t=t=t=t=o=o=o=c=c=c=c=c=a=c=a=c=a=a=c=a=c=c=a=c=c=c=c=c=a.a.a.a.a.a=c=a.a.a.a=c[0[0[0[0[0[0[0[0[0[0[0[0[0[0[0[0[0[0[0[0[0[0[0[0[0]的参数,a=a=a=a=a=a=a=a=a=a=a=a=a=a=资料(“selectpicker”,l=news(this,c,i))}“string”==t&(n=l[t]函数实例的类型?l[t]。应用(l,o):l.options[t])};返回void 0!==n?n:l}s.VERSION=“1.6.2”,s.DEFAULTS={noneSelectedText:“未选择”,nonesulttext:“无结果匹配”,countseletedtext:Function(e,t){return 1==e?”{0}已选择项:{(e,t){var i=[];return i[0]=1==e?“已达到限制({n}项最大值)”:“已达到限制({n}项最大值)”,i[1]=1==t?“已达到组限制({n}项最大值)”:“已达到组限制({n}项最大值)”,i},selectAllText:“全部取消选择”,multipleSeparator:,,,style:“btn默认值”,大小:“自动”,标题:null,selectedTextFormat:“值“,宽度:!1,容器:!1,隐藏禁用:!1,showSubtext:!1,showIcon:!0,showContent:!0,dropupAuto:!0,标题:!1,liveSearch:!1,actionsBox:!1,图标库:“glyphicon”,勾选图标:“glyphicon ok”,maxOptions:!1,mobile:!1,selectOnTab:!1,dropdownAlignRight:!1,SearchAccentResponse:!1},s.prototype={构造函数:s,init:function(){:t=this,i=this.$element:”(“id:);this.$element.hide(),this.multiple=this.$element.prop(“multiple”),this.autofocus=this.$element.prop(“autofocus”),this.$newElement=this.createView(),this.$element.after(this.$newElement),this.$menu=this.$newElement.find(“>.dropdown menu”),this.$button=this.$newElement.find(“>button”),this.$searchbox=this.$newElement.find(“输入”),this.options.dropdownAlignRight&&this.menu.addClass(“下拉菜单右”),void 0!==i&&this.button.attr(“数据id”,i),e('label[for=“+i+””))。单击(函数(e){e.preventDefault(),t.$button.focus()),this.checkDisabled(),this.clickListener(),this.options.liveSearch&&this.liveSearchListener(),this.render(),this.liHeight(),this.setStyle()),this.setWidth(),this.options.container&&this.selectPosition(),this.menu.data(“this”,this),this.newElement.data(“this”,this),this.options.mobile&&this.mobile()},createDropdown:function(){var t=this.multiple?“show tick”:“”,i=this.$element.parent().hasClass(“输入组”)?“输入组btn:”,n=this.autofocus?“自动聚焦”:”,s=this.$element.parents().hasClass(“表单组lg”)?“btn lg”:this.$element.parents().hasClass(“表单组sm”)?“btn sm:”,o=this.options.header?×;“+this.options.header+”:”,a=this.options.liveSearch?“”,l=this.options.actionsBox?“”+this.options。selectAllText+:”;返回e(“+o+a+l+”
    )},createView:function(){var e=this.createDropdown(),t=this.createLi();return e.find(“ul”).append(t),e},reloadLi:function(){this.destrolli();var e=this.createLi();this.$menu.find(“ul”).append(e)},destroili:function(){this.$menu.find(“li”).find”).remove(),createLi:function(){var t=this,s=],o=0,a=function(e,t,i){return”“+e+”“},l=function(e,s,o,a){var l=i(n(e));return'+e+'};return this.$element.find(“option”).each(function(){var i=e(this),n=i.attr(“class”)| |,d=i.attr”(“风格”),r=i.data(“内容”)?i.data:“内容”):i.html(),c=void 0!=i.data(“潜文本”):=i.data=“void=”i.data:“void=”=i.data:“void=”是i.data”(“void=”,i=“void=”,i.data”(“void=”),“void=”是i=“void”(“void索引;索引;如果(如果)如果(如果)如果(如果)如果(如果)如果(如果)如果(如果)如果(如果)如果(如果)如果(如果)如果(如果)如果(如果)如果(如果)h和p和p和p和h以及以及(h+++h+++h+++h+++h+++h+h+h+h+h+h+h+h+h+h+h+“”),i.数据(内容),i.数据(内容)数据(内容)数据(内容)数据(内容)如果(内容)数据(r+内容)是(r+方(r+和(r+和(r+r+r+r+r+c+c+c+c+c+c+c+c+c+c+c+c+c+),,,,,,,,,,,,,!t.t.t.t.选项选项.选项.选项.选项..选项.........选项.难难难难难难难难难(i.父()数据(“图标”)?“”:“)+“”+f+m+”,0!==u和s.length>0和s.push(a(“”,null,“分隔符”)),s.push(a(f,null,“分隔符”))