Explorar o código

a small tweak to empty string handling in select2.val(). issue #34

Igor Vaynberg %!s(int64=13) %!d(string=hai) anos
pai
achega
d0caa9131c
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  1. 2 2
      select2.js

+ 2 - 2
select2.js

@@ -1017,8 +1017,8 @@
                     });
                 this.updateSelection(data);
             } else {
-                // val is an object
-                this.opts.element.val((val === null || val === "") ? "" : val.id);
+                // val is an object. !val is true for [undefined,null,'']
+                this.opts.element.val(!val ? "" : val.id);
                 this.updateSelection(val);
             }
             this.setPlaceholder();