A summary of ComboBox multiple-selection incompatibility issues in jquery _jquery

Source: Internet
Author: User
Recently developed jquery in IE10, a summary of the incompatibility of ComboBox multiple selections in jquery.

When you set the property "Multiple:true" to ComboBox, IE10 cannot complete the multiple selections, and the error is as follows:
Copy Code code as follows:

function _7e8 (_7e9,_7ea) {
var _7eb=$.data (_7e9, "ComboBox");
var opts=_7eb.options;
var _7ec=$ (_7e9). Combo ("GetValues");
var _7ed=_7ec.indexof (_7ea+ "");//10650, here's the error.
if (_7ed>=0) {
_7ec.splice (_7ed,1);
_7e7 (_7E9,_7EC);

That is, the IndexOf method is not supported in F12, and now there are two solutions to this problem:

1. Modify the source code

Amend the code above to
Copy Code code as follows:

<strong>function _7e8 (_7e9,_7ea) {
var _7eb=$.data (_7e9, "ComboBox");
var opts=_7eb.options;
var _7ec=$ (_7e9). Combo ("GetValues");
var _7ed = (function (arr,str) {
str = str + "";
for (Var i=0,l=arr.length;i<l;i++) {
if (arr[i] = = str) return i;
}
return-1;
}) (_7ec,_7ea);
if (_7ed >= 0) {//modified on 2013-6-25 19:04
_7ec.splice (_7ed,1);
_7e7 (_7E9,_7EC);
}</strong>

2. Add IndexOf method
Copy Code code as follows:

<strong>if (! ARRAY.PROTOTYPE.INDEXOF) {
Array.prototype.indexOf = function (target) {
for (Var i=0,l=this.length;i<l;i++) {
if (this[i] = = target) return i;
}
return-1;
};
}</strong>

In fact, I still quite recommend the first method, because more convenient, I was the first way to use.

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.