From 2d58f5b084e358fe326198e111a64e99adf3da70 Mon Sep 17 00:00:00 2001 From: UltCombo Date: Tue, 23 Jul 2013 18:55:09 -0300 Subject: [PATCH 1/2] Fixes #1562; remove some dead code No longer fire change event when .select2('data', falsyValue) is called without the 3rd param; Dead code removed: !"" is true. --- select2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/select2.js b/select2.js index 9207009c..cef3e134 100644 --- a/select2.js +++ b/select2.js @@ -2293,8 +2293,8 @@ the specific language governing permissions and limitations under the Apache Lic if (data == undefined) data = null; return data; } else { - if (!value || value === "") { - this.clear(triggerChange); + if (!value) { + this.clear(!!triggerChange); } else { data = this.data(); this.opts.element.val(!value ? "" : this.id(value)); From 69396da14fc97bbbdc11331ce92c8501d455bc0b Mon Sep 17 00:00:00 2001 From: UltCombo Date: Thu, 25 Jul 2013 21:41:22 -0300 Subject: [PATCH 2/2] data method use the same triggerChange logic as val method --- select2.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/select2.js b/select2.js index cef3e134..00ad0417 100644 --- a/select2.js +++ b/select2.js @@ -2285,16 +2285,20 @@ the specific language governing permissions and limitations under the Apache Lic }, // single - data: function(value, triggerChange) { - var data; + data: function(value) { + var data, + triggerChange = false; if (arguments.length === 0) { data = this.selection.data("select2-data"); if (data == undefined) data = null; return data; } else { + if (arguments.length > 1) { + triggerChange = arguments[1]; + } if (!value) { - this.clear(!!triggerChange); + this.clear(triggerChange); } else { data = this.data(); this.opts.element.val(!value ? "" : this.id(value));