Dynamically read data to Ajax, select ({ID: "", Text: "All"}) id= ""of thevalue option, the option code is dynamically generated in the SELECT element and a call to Val is selected, the problem is that the value of the dynamically generated option is not "", which causes the selection(Firefox environment, others not tested)
The specific order of execution is: (select2.full.js) A. Select the element (if no option is in the original HTML, generate an option based on data and select it)
B. Generating an OPTION element
Create an OPTION element on line 3185When setting the content in line 3188, the text,value of the element option is set by default to the contents of text "All" (Firefox environment, other not tested) in 3194 rows to determine if (data.id) line, when the ID is "", It is not through the "all" that Option.value is the text, which causes the selection.
The workaround is: 1.3194 rows of if (data.id) can be changed to if (Data.id | | data.id=== "") from the remote read through Ajax in $ ("XX"). Select (), after-pass $ ("xx"). Val (""). (If you want to start+ and every time Ajax reads the data after all, the method also needs to modify 3992 rows,SELECT2 4.0 has the same options configured for placeholder and results, and there is no reason for this element in the drop-down result), modify the code to make a bug in your own brain fill it up. 2. In the page HTML code: <select><option value= "" > All </option></select>
From for notes (Wiz)
SELECT2 4.0 ajax/processresults return id= "" Data, can not select