SELECT2 4.0 ajax/processresults return id= "" Data, can not select

Source: Internet
Author: User

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

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.