Remove ajax out-of-order dropping code, handled in updateResults now.
This commit is contained in:
parent
1eb461a42c
commit
2a0cc76236
@ -392,7 +392,6 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
*/
|
*/
|
||||||
function ajax(options) {
|
function ajax(options) {
|
||||||
var timeout, // current scheduled but not yet executed request
|
var timeout, // current scheduled but not yet executed request
|
||||||
requestSequence = 0, // sequence used to drop out-of-order responses
|
|
||||||
handler = null,
|
handler = null,
|
||||||
quietMillis = options.quietMillis || 100,
|
quietMillis = options.quietMillis || 100,
|
||||||
ajaxUrl = options.url,
|
ajaxUrl = options.url,
|
||||||
@ -401,9 +400,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
return function (query) {
|
return function (query) {
|
||||||
window.clearTimeout(timeout);
|
window.clearTimeout(timeout);
|
||||||
timeout = window.setTimeout(function () {
|
timeout = window.setTimeout(function () {
|
||||||
requestSequence += 1; // increment the sequence
|
var data = options.data, // ajax data function
|
||||||
var requestNumber = requestSequence, // this request's sequence number
|
|
||||||
data = options.data, // ajax data function
|
|
||||||
url = ajaxUrl, // ajax url string or function
|
url = ajaxUrl, // ajax url string or function
|
||||||
transport = options.transport || $.fn.select2.ajaxDefaults.transport,
|
transport = options.transport || $.fn.select2.ajaxDefaults.transport,
|
||||||
// deprecated - to be removed in 4.0 - use params instead
|
// deprecated - to be removed in 4.0 - use params instead
|
||||||
@ -433,9 +430,6 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
dataType: options.dataType,
|
dataType: options.dataType,
|
||||||
data: data,
|
data: data,
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
if (requestNumber < requestSequence) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// TODO - replace query.page with query so users have access to term, page, etc.
|
// TODO - 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);
|
||||||
query.callback(results);
|
query.callback(results);
|
||||||
@ -1511,6 +1505,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
input,
|
input,
|
||||||
term = search.val(),
|
term = search.val(),
|
||||||
lastTerm = $.data(this.container, "select2-last-term"),
|
lastTerm = $.data(this.container, "select2-last-term"),
|
||||||
|
// sequence number used to drop out-of-order responses
|
||||||
queryNumber;
|
queryNumber;
|
||||||
|
|
||||||
// prevent duplicate queries against the same term
|
// prevent duplicate queries against the same term
|
||||||
|
Loading…
x
Reference in New Issue
Block a user