From 381f173e553bd5d7837ce912c69aad8c599653a6 Mon Sep 17 00:00:00 2001 From: Mihail Date: Wed, 20 Mar 2013 14:19:05 +0200 Subject: [PATCH] Use $.prop() to get "multiple" attribute The string opts.element.attr("multiple") returns: 1) string "multiple" - if element have attribute multiple () 2) undefined - if element have not attribute multiple () It is written in the documentation: "As of jQuery 1.6, the .attr() method returns undefined for attributes that have not been set." "To retrieve and change DOM properties, use the .prop() method." (http://api.jquery.com/attr/) I am propose use "prop" function. The string opts.element.prop("multiple") returns: 1) boolean "true" - if element have attribute multiple 2) boolean "false" - if element have not attribute multiple After, the "multiple" variable use in check of the condition: select2 = multiple ? new MultiSelect2() : new SingleSelect2(); Better use true/false variable value than "multiple"/undefined in this condition. Tested in Opera 12 and IE 8.0.7601 --- select2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/select2.js b/select2.js index ac542afc..1b3c1baf 100644 --- a/select2.js +++ b/select2.js @@ -2667,7 +2667,7 @@ the specific language governing permissions and limitations under the Apache Lic opts.element = $(this); if (opts.element.get(0).tagName.toLowerCase() === "select") { - multiple = opts.element.attr("multiple"); + multiple = opts.element.prop("multiple"); } else { multiple = opts.multiple || false; if ("tags" in opts) {opts.multiple = multiple = true;}