collapsibleContainer.js: Don't expect a data attribute for a container's id

This commit is contained in:
Johannes Meyer 2019-06-06 10:16:00 +02:00
parent e6e43d07bf
commit ffe638ee36
1 changed files with 13 additions and 3 deletions

View File

@ -33,9 +33,14 @@
CollapsibleContainer.prototype.onRendered = function(event) { CollapsibleContainer.prototype.onRendered = function(event) {
var _this = event.data.self; 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); 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) { if ($this.find('.collapsible').length > 0) {
$this.addClass('has-collapsible'); $this.addClass('has-collapsible');
if ($this.find('.collapsible').innerHeight() > ($this.data('height') || _this.defaultHeight)) { if ($this.find('.collapsible').innerHeight() > ($this.data('height') || _this.defaultHeight)) {
@ -51,9 +56,14 @@
_this.updateCollapsedState($this); _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); 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) { if ($this.find('.collapsible').length > 0) {
$this.addClass('has-collapsible'); $this.addClass('has-collapsible');
if ($this.find('tr').length > ($this.attr('data-numofrows') || _this.defaultNumOfRows)) { if ($this.find('tr').length > ($this.attr('data-numofrows') || _this.defaultNumOfRows)) {
@ -101,7 +111,7 @@
$collapsible = $container; $collapsible = $container;
} }
var collapsibleId = $container.data('collapsibleId'); var collapsibleId = $container.attr('id');
if (typeof this.expandedContainers[collapsibleId] === 'undefined') { if (typeof this.expandedContainers[collapsibleId] === 'undefined') {
this.expandedContainers[collapsibleId] = false; this.expandedContainers[collapsibleId] = false;
} }