loader.js: Only pre-wrap a search response's html with a div

It's not required for all responses anymore.

refs #3953
This commit is contained in:
Johannes Meyer 2019-09-23 08:49:19 +02:00
parent d699191629
commit b15c012671
1 changed files with 25 additions and 29 deletions

View File

@ -445,8 +445,6 @@
_this.loadUrl(_this.url('/layout/announcements'), $('#announcements'));
}
// div helps getting an XML tree
var $resp = $('<div>' + req.responseText + '</div>');
var active = false;
var rendered = false;
var classes;
@ -521,11 +519,9 @@
}
// Handle search requests, still hardcoded.
if (req.url.match(/^\/search/) &&
req.$target.data('icingaUrl').match(/^\/search/) &&
$('.dashboard', $resp).length > 0 &&
$('.dashboard .container', req.$target).length > 0)
{
if (req.url.match(/^\/search/) && req.$target.data('icingaUrl').match(/^\/search/)) {
var $resp = $('<div>' + req.responseText + '</div>'); // div helps getting an XML tree
if ($('.dashboard', $resp).length > 0 && $('.dashboard .container', req.$target).length > 0) {
// TODO: We need dashboard pane and container identifiers (not ids)
var targets = [];
$('.dashboard .container', req.$target).each(function (idx, el) {
@ -549,6 +545,7 @@
});
rendered = true;
}
}
var referrer = req.referrer;
if (typeof referrer === 'undefined') {
@ -574,8 +571,7 @@
this.icinga.timer.unregister(req.progressTimer);
}
// .html() removes outer div we added above
this.renderContentToContainer($resp.html(), req.$target, req.action, req.autorefresh, req.forceFocus, autoSubmit);
this.renderContentToContainer(req.responseText, req.$target, req.action, req.autorefresh, req.forceFocus, autoSubmit);
if (oldNotifications) {
oldNotifications.appendTo($('#notifications'));
}