diff --git a/select2.js b/select2.js index 10bb75fc..55836c72 100755 --- a/select2.js +++ b/select2.js @@ -72,7 +72,7 @@ function indexOf(value, array) { var i = 0, l = array.length, v; - if (typeof value == 'undefined') { + if (typeof value === "undefined") { return -1; } @@ -246,7 +246,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); } }); @@ -650,12 +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 - }); + } + if (this.opts.dropdownZIndex !== undefined) { + css["z-index"] = this.opts.dropdownZIndex + } + this.dropdown.css(css); }, open: function () { @@ -832,6 +834,9 @@ callback: this.bind(function (data) { var 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); @@ -1570,7 +1575,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);