1, in the official online example, there has been no search box out, has been the ordinary <select> tag to achieve the effect of it. Tangled up for a long time did not know what happened, later open the browser developer tool, found that prompted the following figure error:
Suddenly realized that he was a fool, Select2 is a plug-in based on jquery, no reference jquery,select2 swelling may be useful. I'm so stupid,-_-!.
Also blame oneself is not good, direct the code of the Guan net to write once to run directly.
2, in the implementation of adding placeholder effect to select2, the problem of placeholder does not work, ah, really tangled up for a long time, finally please vision to help look at, only to find that The original is that I did not give Select2 a placeholder opportunity, did not give Select2 an empty option,select2 swollen there is a place to show placeholder to show the content of it .
3, when doing SELECT2 data array, need to pay attention to two points: (1) to use the <input type= "hidden" > label instead of <select> label; (2) Each data in the array must have an ID and a text two field.
Also, when I was doing this example, I accidentally wrote a colon in the code, causing the Select2 control to load on the page, but I learned to find the error through the developer tool:
Parameter minimuminputlength,allowclear are case-sensitive and are not effective if the case is incorrect