various small fixes. closes #99
This commit is contained in:
parent
94ffecb824
commit
d62bc5bef1
11
select2.js
11
select2.js
@ -70,7 +70,7 @@
|
|||||||
function indexOf(value, array) {
|
function indexOf(value, array) {
|
||||||
var i = 0, l = array.length, v;
|
var i = 0, l = array.length, v;
|
||||||
|
|
||||||
if (typeof value == 'undefined') {
|
if (typeof value === "undefined") {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,7 +244,6 @@
|
|||||||
}
|
}
|
||||||
// TODO 3.0 - replace query.page with query so users have access to term, page, etc.
|
// TODO 3.0 - replace query.page with query so users have access to term, page, etc.
|
||||||
var results = options.results(data, query.page);
|
var results = options.results(data, query.page);
|
||||||
self.context = results.context;
|
|
||||||
query.callback(results);
|
query.callback(results);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -678,8 +677,8 @@
|
|||||||
this.opts.query({
|
this.opts.query({
|
||||||
term: this.search.val(),
|
term: this.search.val(),
|
||||||
page: page,
|
page: page,
|
||||||
context: self.context,
|
context: this.context,
|
||||||
matcher: self.opts.matcher,
|
matcher: this.opts.matcher,
|
||||||
callback: this.bind(function (data) {
|
callback: this.bind(function (data) {
|
||||||
var parts = [], self = this;
|
var parts = [], self = this;
|
||||||
$(data.results).each(function () {
|
$(data.results).each(function () {
|
||||||
@ -740,6 +739,9 @@
|
|||||||
var parts = [], // html parts
|
var parts = [], // html parts
|
||||||
def; // default choice
|
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
|
// create a default choice and prepend it to the list
|
||||||
if (this.opts.createSearchChoice && search.val() !== "") {
|
if (this.opts.createSearchChoice && search.val() !== "") {
|
||||||
def = this.opts.createSearchChoice.call(null, search.val(), data.results);
|
def = this.opts.createSearchChoice.call(null, search.val(), data.results);
|
||||||
@ -1478,7 +1480,6 @@
|
|||||||
val = (val === null) ? [] : val;
|
val = (val === null) ? [] : val;
|
||||||
this.setVal(val);
|
this.setVal(val);
|
||||||
// val is a list of objects
|
// val is a list of objects
|
||||||
st
|
|
||||||
$(val).each(function () { data.push(self.id(this)); });
|
$(val).each(function () { data.push(self.id(this)); });
|
||||||
this.setVal(data);
|
this.setVal(data);
|
||||||
this.updateSelection(val);
|
this.updateSelection(val);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user