BootStrap selectpicker, selectpicker

Source: Internet
Author: User

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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.