Skip to content

Commit d62bc5b

Browse files
committed
various small fixes. closes select2#99
1 parent 94ffecb commit d62bc5b

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

select2.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
function indexOf(value, array) {
7171
var i = 0, l = array.length, v;
7272

73-
if (typeof value == 'undefined') {
73+
if (typeof value === "undefined") {
7474
return -1;
7575
}
7676

@@ -244,7 +244,6 @@
244244
}
245245
// TODO 3.0 - replace query.page with query so users have access to term, page, etc.
246246
var results = options.results(data, query.page);
247-
self.context = results.context;
248247
query.callback(results);
249248
}
250249
});
@@ -678,8 +677,8 @@
678677
this.opts.query({
679678
term: this.search.val(),
680679
page: page,
681-
context: self.context,
682-
matcher: self.opts.matcher,
680+
context: this.context,
681+
matcher: this.opts.matcher,
683682
callback: this.bind(function (data) {
684683
var parts = [], self = this;
685684
$(data.results).each(function () {
@@ -740,6 +739,9 @@
740739
var parts = [], // html parts
741740
def; // default choice
742741

742+
// save context, if any
743+
this.context = (data.context===undefined) ? null : data.context;
744+
743745
// create a default choice and prepend it to the list
744746
if (this.opts.createSearchChoice && search.val() !== "") {
745747
def = this.opts.createSearchChoice.call(null, search.val(), data.results);
@@ -1478,7 +1480,6 @@
14781480
val = (val === null) ? [] : val;
14791481
this.setVal(val);
14801482
// val is a list of objects
1481-
st
14821483
$(val).each(function () { data.push(self.id(this)); });
14831484
this.setVal(data);
14841485
this.updateSelection(val);

0 commit comments

Comments
 (0)