From ffe638ee365d9d935415264ca8a3a5c095dd707e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 6 Jun 2019 10:16:00 +0200 Subject: [PATCH] collapsibleContainer.js: Don't expect a data attribute for a container's id --- .../js/icinga/behavior/collapsibleContainer.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/public/js/icinga/behavior/collapsibleContainer.js b/public/js/icinga/behavior/collapsibleContainer.js index 1eb344061..74f1f7f15 100644 --- a/public/js/icinga/behavior/collapsibleContainer.js +++ b/public/js/icinga/behavior/collapsibleContainer.js @@ -33,9 +33,14 @@ CollapsibleContainer.prototype.onRendered = function(event) { var _this = event.data.self; - $(event.target).find('.collapsible-container[data-collapsible-id]').each(function() { + $(event.target).find('.collapsible-container').each(function() { var $this = $(this); + if (typeof $this.attr('id') === 'undefined') { + _this.icinga.logger.warn('[collapsible] Container has no id: ', this); + return; + } + if ($this.find('.collapsible').length > 0) { $this.addClass('has-collapsible'); if ($this.find('.collapsible').innerHeight() > ($this.data('height') || _this.defaultHeight)) { @@ -51,9 +56,14 @@ _this.updateCollapsedState($this); }); - $(event.target).find('.collapsible-table-container[data-collapsible-id]').each(function() { + $(event.target).find('.collapsible-table-container').each(function() { var $this = $(this); + if (typeof $this.attr('id') === 'undefined') { + _this.icinga.logger.warn('[collapsible] Container has no id: ', this); + return; + } + if ($this.find('.collapsible').length > 0) { $this.addClass('has-collapsible'); if ($this.find('tr').length > ($this.attr('data-numofrows') || _this.defaultNumOfRows)) { @@ -101,7 +111,7 @@ $collapsible = $container; } - var collapsibleId = $container.data('collapsibleId'); + var collapsibleId = $container.attr('id'); if (typeof this.expandedContainers[collapsibleId] === 'undefined') { this.expandedContainers[collapsibleId] = false; }