I hate flickering search result, fixed one more time

This commit is contained in:
Thomas Gelf 2014-03-26 18:01:20 +00:00
parent 2360f21b09
commit 4b47841dc2

View File

@ -233,7 +233,8 @@
'Got response for ', req.$target, ', URL was ' + url 'Got response for ', req.$target, ', URL was ' + url
); );
var $resp = $(req.responseText); // div helps getting an XML tree
var $resp = $('<div>' + req.responseText + '</div>');
var active = false; var active = false;
var rendered = false; var rendered = false;
@ -334,8 +335,9 @@
// Handle search requests, still hardcoded. // Handle search requests, still hardcoded.
if (req.url.match(/^\/search/) && if (req.url.match(/^\/search/) &&
req.$target.data('icingaUrl').match(/^\/search/) req.$target.data('icingaUrl').match(/^\/search/) &&
&& $('.dashboard', $resp).length > 0) $('.dashboard', $resp).length > 0 &&
$('.dashboard .container', req.$target).length > 0)
{ {
// TODO: We need dashboard pane and container identifiers (not ids) // TODO: We need dashboard pane and container identifiers (not ids)
var targets = []; var targets = [];
@ -345,8 +347,13 @@
var i = 0; var i = 0;
// Searching for '.dashboard .container' in $resp doesn't dork?! // Searching for '.dashboard .container' in $resp doesn't dork?!
$('.container', $resp).each(function (idx, el) { $('.dashboard .container', $resp).each(function (idx, el) {
var $el = $(el); var $el = $(el);
if ($el.hasClass('dashboard')) {
return;
} else {
}
var url = $el.data('icingaUrl'); var url = $el.data('icingaUrl');
targets[i].data('icingaUrl', url); targets[i].data('icingaUrl', url);
var title = $('h1', $el).first(); var title = $('h1', $el).first();
@ -408,7 +415,8 @@
return; return;
} }
this.renderContentToContainer($resp, req.$target); // .html() removes outer div we added above
this.renderContentToContainer($resp.html(), req.$target);
if (url.match(/#/)) { if (url.match(/#/)) {
this.icinga.ui.scrollContainerToAnchor(req.$target, url.split(/#/)[1]); this.icinga.ui.scrollContainerToAnchor(req.$target, url.split(/#/)[1]);
} }