소스 검색

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

Igor Vaynberg 13 년 전
부모
커밋
d0caa9131c
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  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();