BootStrap selectpicker, selectpicker
Mark a small issue encountered when bootstrap selectpicker is used as the next error
$ ('. Selectpicker '). selectpicker ('val ', 'mustard'); // single choice $ ('. selectpicker '). selectpicker ('val', ['mustard ', 'relish']); // select $ ('. selectpicker '). selectpicker ('refresh'); refresh the display
Mark the question: the val must be the value in option. How can I disable it if I use name.
PS: select beautification (bootstrap)
Files to be introduced:
Bootstrap-combined.min.css
Bootstrap-select.css
Bootstrap-select.js
And several frequently-used bootstarp files such as bootstrap. min. js.
Implementation:
1. Add a class or id to the <select> label. We recommend that you add a class because the class can be repeated;
2. Add the initialization method to the js file:
InitFnc: function () {$ (". selectpicker"). selectpicker ({noneSelectedText: 'select '});}
Call this method during external initialization!
After the beautification: Not very nice, but I think it is much better than before!
However, there are several problems with this beautification plug-in:
In fact, it is not a few, but I think this problem is very difficult. After using this method to beautify, the dynamic value assignment <select> will show the method, I think it should be like this: in the bootstrap-select.js, the <select> display without option is 'Please input ', so that the option of Dynamic assignment will not be written in! If you can fix noneSelectedText: ', select'. This problem can be solved!
After several hours of research, I found the problem, but only solved one of them;
When calling in js, you must wait until the option in the select statement on the interface is loaded.
InitFnc: function () {$ (". selectpicker"). selectpicker ({noneSelectedText: 'select '});}
In this way, the dynamic select assignment can also be beautified, but there is still a problem: Not every select on the page can be fully loaded during page initialization, for example: now there are two associated select statements, that is, the option of the second select must be changed with the first one. Add monitoring onchange or change in js. If so, there is a problem!
The above is the introduction of BootStrap selectpicker. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!