From ad8fd257aa622a7ae5dee7963e9d9908bf8d9859 Mon Sep 17 00:00:00 2001 From: Dean Sofer Date: Fri, 20 Jul 2012 19:15:46 -0700 Subject: [PATCH] Added truth checks to avoid unnecessarily firing initSelection. Signed-off-by: Igor Vaynberg --- select2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/select2.js b/select2.js index 0ffa3064..d7f4848a 100755 --- a/select2.js +++ b/select2.js @@ -1448,7 +1448,7 @@ this.updateSelection(data); } else { // val is an object. !val is true for [undefined,null,''] - if (this.opts.initSelection) { + if (this.opts.initSelection && val) { that = this; this.opts.initSelection(this.opts.element.val(val), function(data){ self.opts.element.val(!data ? "" : self.id(data)); @@ -1915,7 +1915,7 @@ }); this.updateSelection(data); } else { - if (this.opts.initSelection) { + if (this.opts.initSelection && val !== null) { this.opts.initSelection(this.opts.element.val(val), function(newVal){ $(newVal).each(function () { data.push(self.id(this)); }); self.setVal(data);