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.