From d62bc5bef1ff6696262c3eb03334c553dc68f897 Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Tue, 12 Jun 2012 19:41:21 -0700 Subject: [PATCH 1/3] various small fixes. closes #99 --- select2.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/select2.js b/select2.js index e2a8db5c..788d1ed9 100755 --- a/select2.js +++ b/select2.js @@ -70,7 +70,7 @@ function indexOf(value, array) { var i = 0, l = array.length, v; - if (typeof value == 'undefined') { + if (typeof value === "undefined") { return -1; } @@ -244,7 +244,6 @@ } // TODO 3.0 - replace query.page with query so users have access to term, page, etc. var results = options.results(data, query.page); - self.context = results.context; query.callback(results); } }); @@ -678,8 +677,8 @@ this.opts.query({ term: this.search.val(), page: page, - context: self.context, - matcher: self.opts.matcher, + context: this.context, + matcher: this.opts.matcher, callback: this.bind(function (data) { var parts = [], self = this; $(data.results).each(function () { @@ -740,6 +739,9 @@ var parts = [], // html parts def; // default choice + // save context, if any + 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); @@ -1478,7 +1480,6 @@ val = (val === null) ? [] : val; this.setVal(val); // val is a list of objects - st $(val).each(function () { data.push(self.id(this)); }); this.setVal(data); this.updateSelection(val); From 277ae4ff5ab604635b5dca3c3ec1d98ed1dfe0d5 Mon Sep 17 00:00:00 2001 From: Pier-Olivier Thibault Date: Thu, 14 Jun 2012 07:14:49 -0400 Subject: [PATCH 2/3] Added zindex options to dropdown so we can make sure it presents itself on top of whatever is existing in the DOM --- select2.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/select2.js b/select2.js index 7f3cbe37..7ac2f77d 100755 --- a/select2.js +++ b/select2.js @@ -539,6 +539,7 @@ formatInputTooShort: function (input, min) { return "Please enter " + (min - input.length) + " more characters"; }, minimumResultsForSearch: 0, minimumInputLength: 0, + zIndex: 2000, id: function (e) { return e.id; }, matcher: function(term, text) { return text.toUpperCase().indexOf(term.toUpperCase()) >= 0; @@ -653,7 +654,8 @@ this.dropdown.css({ top: offset.top + height, left: offset.left, - width: width + width: width, + "z-index": this.opts.zIndex }); }, From 5941fcea25fc7e82f7bc134289647381edd19096 Mon Sep 17 00:00:00 2001 From: Pier-Olivier Thibault Date: Thu, 14 Jun 2012 12:03:38 -0400 Subject: [PATCH 3/3] Using dropdownZIndex as opts. Dropping default value so use can set it via css. --- select2.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/select2.js b/select2.js index 7ac2f77d..55836c72 100755 --- a/select2.js +++ b/select2.js @@ -539,7 +539,6 @@ formatInputTooShort: function (input, min) { return "Please enter " + (min - input.length) + " more characters"; }, minimumResultsForSearch: 0, minimumInputLength: 0, - zIndex: 2000, id: function (e) { return e.id; }, matcher: function(term, text) { return text.toUpperCase().indexOf(term.toUpperCase()) >= 0; @@ -650,13 +649,15 @@ var offset = this.container.offset(); var height = this.container.outerHeight(); var width = this.container.outerWidth(); - - this.dropdown.css({ + var css = { top: offset.top + height, left: offset.left, - width: width, - "z-index": this.opts.zIndex - }); + width: width + } + if (this.opts.dropdownZIndex !== undefined) { + css["z-index"] = this.opts.dropdownZIndex + } + this.dropdown.css(css); }, open: function () {