1
0
mirror of synced 2024-11-30 00:26:03 +03:00

fix ajax url() context. fixes #895

This commit is contained in:
Igor Vaynberg 2013-02-19 13:21:57 -08:00
parent 9bf4614cd5
commit 70be25cc6d

View File

@ -341,7 +341,8 @@ the specific language governing permissions and limitations under the Apache Lic
requestSequence = 0, // sequence used to drop out-of-order responses 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,
self = this;
return function (query) { return function (query) {
window.clearTimeout(timeout); window.clearTimeout(timeout);
@ -354,14 +355,14 @@ the specific language governing permissions and limitations under the Apache Lic
type = options.type || 'GET', // set type of request (GET or POST) type = options.type || 'GET', // set type of request (GET or POST)
params = {}; params = {};
data = data ? data.call(this, query.term, query.page, query.context) : null; data = data ? data.call(self.opts.element, query.term, query.page, query.context) : null;
url = (typeof url === 'function') ? url.call(this, query.term, query.page, query.context) : url; url = (typeof url === 'function') ? url.call(self.opts.element, query.term, query.page, query.context) : url;
if( null !== handler) { handler.abort(); } if( null !== handler) { handler.abort(); }
if (options.params) { if (options.params) {
if ($.isFunction(options.params)) { if ($.isFunction(options.params)) {
$.extend(params, options.params.call(null)); $.extend(params, options.params.call(self.opts.element));
} else { } else {
$.extend(params, options.params); $.extend(params, options.params);
} }
@ -382,7 +383,7 @@ the specific language governing permissions and limitations under the Apache Lic
query.callback(results); query.callback(results);
} }
}); });
handler = transport.call(null, params); handler = transport.call(self.opts.element, params);
}, quietMillis); }, quietMillis);
}; };
} }