From d0caa9131c69e969712aeb555494235ed7a56ef9 Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Tue, 17 Apr 2012 08:05:14 -0700 Subject: [PATCH] a small tweak to empty string handling in select2.val(). issue #34 --- select2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/select2.js b/select2.js index c944514f..b432d461 100755 --- a/select2.js +++ b/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();