Use $.prop() to get "multiple" attribute
The string
opts.element.attr("multiple")
returns:
1) string "multiple" - if element have attribute multiple (<select name="..." multiple></select>)
2) undefined - if element have not attribute multiple (<select name="..."></select>)
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