From b034a558844991702cfc2e1cfa4e0924ee43582b Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Tue, 17 Apr 2012 08:04:00 -0700 Subject: [PATCH 1/3] added todo for placeholder validation --- select2.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/select2.js b/select2.js index 467ee8bd..04938b1a 100755 --- a/select2.js +++ b/select2.js @@ -1052,6 +1052,9 @@ prepareOpts: function () { var opts = this.parent.prepareOpts.apply(this, arguments); + + // TODO validate placeholder is a string if specified + if (opts.element.get(0).tagName.toLowerCase() === "select") { // install sthe selection initializer this.opts.initSelection = function (element) { From d0caa9131c69e969712aeb555494235ed7a56ef9 Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Tue, 17 Apr 2012 08:05:14 -0700 Subject: [PATCH 2/3] 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(); From 5ccee14cee027102beabc3e578509512b0fb8fd7 Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Tue, 17 Apr 2012 08:16:22 -0700 Subject: [PATCH 3/3] remove event bindings on destroy. closes #35 closes #36 --- select2.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/select2.js b/select2.js index b432d461..05b5c48b 100755 --- a/select2.js +++ b/select2.js @@ -419,6 +419,7 @@ select2.container.remove(); select2.opts.element .removeData("select2") + .unbind(".select2") .show(); } }, @@ -503,7 +504,7 @@ * Monitor the original element for changes and update select2 accordingly */ monitorSource: function () { - this.opts.element.bind("change", this.bind(function (e) { + this.opts.element.bind("change.select2", this.bind(function (e) { if (this.opts.element.data("select2-change-triggered") !== true) { this.initSelection(); }