mark a small issue encountered by using bootstrap selectpicker, and use it as the next time you check the error
$('.selectpicker').selectpicker('val', 'Musstard');//Single-select$('.selectpicker').selectpicker('val', ['Musstard','Relish']);//Multiple-select$('.selectpicker').selectpicker('refresh'); can refresh the displaymark the question: the set val must be the value value in the option, and if name is used, why does not take effect?
PS: select beautification (bootstrap)
Files that need to be introduced:
bootstrap-combined.min.css
bootstrap-select.css
bootstrap-select.js
As well as several commonly used bootstarp files such as bootstrap.min.js
accomplish:
1. Add class or id in the <select> tag. It is recommended to add class because class can be repeated;
2. Add initialization method to the js file:
initFnc : function(){$(".selectpicker").selectpicker({noneSelectedText:'Please select'});}Calling this method during external initialization is OK!
The picture below is beautified: it is not very good, but I think it is much better than before!
However, there are several problems with this beautification plugin:
Actually, there are not many, but I think this problem is very tricky. After using this method to beautify it, the dynamically assigned <select> will be displayed. I think it should be like this: bootstrap-select.js displays <select> without option 'Please enter', so that the dynamically assigned option cannot be written in! If noneSelectedText:'Please select' can be fixed, then this problem should be solved!
After several hours of research, the problem was found, but only one of them was solved;
When calling in js, you must wait until the option in select on the surface is loaded before calling
initFnc : function(){$(".selectpicker").selectpicker({noneSelectedText:'Please select'});}This way, dynamic select assignment can also beautify, but there is still a problem: not every select on the page can be loaded all when the page is initialized. For example, there are now two linked select options, that is, the option of the second select needs to change according to the first, and add monitoring onchange or change in js; if beautify this way, there will be problems!
The above is the relevant knowledge about BootStrap selectpicker introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to Wulin.com website!