BootStrap Selectpicker_javascript Skills

Source: Internet
Author: User

Mark the use of a small issue encountered by Bootstrap Selectpicker as the next error-checking

$ ('. Selectpicker '). Selectpicker (' Val ', ' mustard ');//Radio

Mark the problem: the Val set must be the value in option, and if it doesn't work with name.

Ps:select Landscaping (Bootstrap)

Files to be introduced:

Bootstrap-combined.min.css
Bootstrap-select.css
Bootstrap-select.js

and several common bootstarp files such as Bootstrap.min.js.

Realize:

1, add class or ID in <select> tag, it is recommended to add class, because class can be repeated;

2, in the JS file to add initialization method:

Initfnc:function () {
$ (". Selectpicker"). Selectpicker ({noneselectedtext: ' Please select '});
}

This method is invoked when external initialization is ok!

The following image is landscaping: not very good-looking, but I feel much better than before!

But this landscaping plugin has several problems:

In fact, not a few, but I think this problem is very tricky, after using this method to beautify, dynamic assignment of <select> will be shown, I think it should be: bootstrap-select.js in the option of <select> Show ' Please enter ' so that the dynamic assignment option will not be written! If you can put noneselectedtext: ' Please choose ' to fix, then this problem should be able to solve!

After a few hours of research, found the problem, but only to solve one of them;

When calling in JS, be sure to wait for the option on the face to be loaded and then adjust

Initfnc:function () {
$ (". Selectpicker"). Selectpicker ({noneselectedtext: ' Please select '});
}

This will also beautify the dynamic select assignment. But there is still a problem: Not every select on the page can be loaded when the page is initialized, for example: Now there are two simultaneous select, the option of the second select to change with the first , add the monitor onchange or change in JS, if this beautification has the question!

The above is a small set to introduce the bootstrap selectpicker of the relevant knowledge, hope to help everyone, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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.