How can I set the default value for this plug-in javascript-Select2?

Source: Internet
Author: User
How can I set the default value for the Select2 plug-in? After submitting the file, I received an array. After storing the file in the database, I needed to set the previously submitted array to the plug-in as the default value. However, I tried various methods, such as JSON and string, but this product is not recognized .. Input select box 1... how does the plug-in Select2 give him the default value? After submitting the file, I received an array. After storing the file in the database, I needed to set the previously submitted array to the plug-in as the default value. However, I tried various methods, such as JSON and string, but this product is not recognized .. The input selection box is always blank. The setting method is used. The official manual only uses instances. The demo is very concise and cannot find the part I want...

Reply content:

How can I set the default value for the Select2 plug-in? After submitting the file, I received an array. After storing the file in the database, I needed to set the previously submitted array to the plug-in as the default value. However, I tried various methods, such as JSON and string, but this product is not recognized .. The input selection box is always blank. The setting method is used. The official manual only uses instances. The demo is very concise and cannot find the part I want...

Add the selected Attribute directly when you fill in the option.

                                             test1                                            test2                                            test3                                        

If you fill in option in js, you can also, but you need to put the plug-in's initialization function select2 () after you fill in the option step.

The default value also requires an array.

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.