From 837aa436e5b31a06a8fab1a7bfcfdf97ab877f2b Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 13 Nov 2013 16:18:32 +0100 Subject: [PATCH] [IMP] abort FAYT requests when the next one comes in bzr revid: xmo@openerp.com-20131113151832-ym4hvpyhn5t7ocxs --- addons/website/static/src/js/website.editor.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 994876d6c05..245abd9960e 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -845,8 +845,9 @@ }), init: function (editor) { this._super(editor); - // url -> name mapping for existing pages this.text = null; + // Store last-performed request to be able to cancel/abort it. + this.req = null; }, start: function () { var self = this; @@ -941,7 +942,9 @@ .addBack().removeClass('has-error'); }, fetch_pages: function (term) { - return openerp.jsonRpc('/web/dataset/call_kw', 'call', { + var self = this; + if (this.req) { this.req.abort(); } + return this.req = openerp.jsonRpc('/web/dataset/call_kw', 'call', { model: 'website', method: 'search_pages', args: [null, term], @@ -949,6 +952,9 @@ limit: 9, context: website.get_context() }, + }).done(function () { + // request completed successfully -> unstore it + self.req = null; }); }, });