luci-base: xhr.js: defer starting poll queue

Defer the start of the queue poll loop until the document has been loaded.

This allows all XHR.poll() invocations on the page to register their
handlers before the first batch of requests is made.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
Jo-Philipp Wich 2018-06-22 09:39:30 +02:00
parent e380cf51f8
commit 69782ccbcc

View file

@ -204,7 +204,6 @@ XHR.poll = function(interval, url, data, callback, post)
};
XHR._q.push(e);
XHR.run();
return e;
}
@ -260,3 +259,5 @@ XHR.running = function()
{
return !!(XHR._r && XHR._i);
}
document.addEventListener('DOMContentLoaded', XHR.run);