From 338a1260679d32b05d482b5585e502709e310359 Mon Sep 17 00:00:00 2001 From: Jeff Hanke Date: Thu, 20 Jun 2013 18:36:12 -0700 Subject: [PATCH] Always call createSearchChoice and tokenizer with the Select2 object as this. --- select2.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/select2.js b/select2.js index 90860747..b7eb34c3 100644 --- a/select2.js +++ b/select2.js @@ -598,7 +598,7 @@ the specific language governing permissions and limitations under the Apache Lic input = input.substring(index + separator.length); if (token.length > 0) { - token = opts.createSearchChoice(token, selection); + token = opts.createSearchChoice.call(this, token, selection); if (token !== undefined && token !== null && opts.id(token) !== undefined && opts.id(token) !== null) { dupe = false; for (i = 0, l = selection.length; i < l; i++) { @@ -1586,7 +1586,7 @@ the specific language governing permissions and limitations under the Apache Lic this.context = (data.context===undefined) ? null : data.context; // create a default choice and prepend it to the list if (this.opts.createSearchChoice && search.val() !== "") { - def = this.opts.createSearchChoice.call(null, search.val(), data.results); + def = this.opts.createSearchChoice.call(self, search.val(), data.results); if (def !== undefined && def !== null && self.id(def) !== undefined && self.id(def) !== null) { if ($(data.results).filter( function () { @@ -2640,7 +2640,7 @@ the specific language governing permissions and limitations under the Apache Lic // multi tokenize: function() { var input = this.search.val(); - input = this.opts.tokenizer(input, this.data(), this.bind(this.onSelect), this.opts); + input = this.opts.tokenizer.call(this, input, this.data(), this.bind(this.onSelect), this.opts); if (input != null && input != undefined) { this.search.val(input); if (input.length > 0) {