简体   繁体   English

从Boostrap中排除元素以选择实时搜索

[英]Exclude element from Boostrap select live search

I am using bootstrap select with live search and I would like to have an element always visible. 我在实时搜索中使用引导选择 ,我希望元素始终可见。 Example: 例:

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/css/bootstrap-select.min.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/js/bootstrap-select.min.js"></script> <select data-live-search="true" class="selectpicker"> <option>mustard</option> <option>ketchup</option> <option>relish</option> <option data-divider="true"></option> <option>Add new</option> </select> 

I would like the "Add new" option to always be shown (before searching and after searching with and without results found). 我希望始终显示“添加新”选项(在搜索之前和搜索之后,无论是否找到结果)。 I couldn't find any way to do this. 我找不到任何方法可以做到这一点。 The approach I am considering is to manually append an element to the list using Javascript when the load event is triggered. 我正在考虑的方法是在触发加载事件时使用Javascript将元素手动添加到列表中。

If you are using CDN, then its quite impossible in my case to make you understand how to do this. 如果您使用的是CDN,那么就我而言,这完全不可能使您了解如何执行此操作。

Other than, if you are using its JS & CSS file from local, then there is some configuration in JS file ie if no option is there then it will show "Nothing Selected". 除此之外,如果您从本地使用其JS&CSS文件,则JS文件中有一些配置,即如果没有选项,则它将显示“ Nothing Selected”。 You can search for the Particular text and can Change from there. 您可以搜索特殊文本,并可以从此处更改。

Because of its a plugin, you can't customize it completely. 由于有插件,因此无法完全自定义。

Its not the best answer, but it might help you 它不是最佳答案,但可能会对您有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM