js: Fix regression for loading dependent modules for sub-containers (#4533)
This commit is contained in:
parent
08c51d27a6
commit
d4763498e4
|
@ -163,6 +163,37 @@
|
||||||
return 'undefined' !== typeof this.modules[name];
|
return 'undefined' !== typeof this.modules[name];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure we have loaded the javascript code for a module
|
||||||
|
*
|
||||||
|
* @param {string} moduleName
|
||||||
|
*/
|
||||||
|
ensureModule: function(moduleName) {
|
||||||
|
if (this.hasModule(moduleName) && ! this.isLoadedModule(moduleName)) {
|
||||||
|
this.loadModule(moduleName);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If a container contains sub-containers for other modules,
|
||||||
|
* make sure the javascript code for each module is loaded.
|
||||||
|
*
|
||||||
|
* Containers are identified by "data-icinga-module" which
|
||||||
|
* holds the module name.
|
||||||
|
*
|
||||||
|
* @param container
|
||||||
|
*/
|
||||||
|
ensureSubModules: function (container) {
|
||||||
|
var icinga = this;
|
||||||
|
|
||||||
|
$(container).find('[data-icinga-module]').each(function () {
|
||||||
|
var moduleName = $(this).data('icingaModule');
|
||||||
|
if (moduleName) {
|
||||||
|
icinga.ensureModule(moduleName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a module by name
|
* Get a module by name
|
||||||
*
|
*
|
||||||
|
|
|
@ -35,16 +35,8 @@
|
||||||
behavior.bind($(document));
|
behavior.bind($(document));
|
||||||
});
|
});
|
||||||
|
|
||||||
var _this = this;
|
|
||||||
$('.container').each(function () {
|
|
||||||
// Initialize module javascript (Applies only to module.js code)
|
// Initialize module javascript (Applies only to module.js code)
|
||||||
var moduleName = $(this).data('icingaModule');
|
this.icinga.ensureSubModules(document);
|
||||||
if (moduleName) {
|
|
||||||
if (_this.icinga.hasModule(moduleName) && ! _this.icinga.isLoadedModule(moduleName)) {
|
|
||||||
_this.icinga.loadModule(moduleName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// We catch resize events
|
// We catch resize events
|
||||||
$(window).on('resize', { self: this.icinga.ui }, this.icinga.ui.onWindowResize);
|
$(window).on('resize', { self: this.icinga.ui }, this.icinga.ui.onWindowResize);
|
||||||
|
|
|
@ -734,9 +734,7 @@
|
||||||
});
|
});
|
||||||
if (moduleName) {
|
if (moduleName) {
|
||||||
// Lazy load module javascript (Applies only to module.js code)
|
// Lazy load module javascript (Applies only to module.js code)
|
||||||
if (_this.icinga.hasModule(moduleName) && ! _this.icinga.isLoadedModule(moduleName)) {
|
_this.icinga.ensureModule(moduleName);
|
||||||
_this.icinga.loadModule(moduleName);
|
|
||||||
}
|
|
||||||
|
|
||||||
req.$target.data('icingaModule', moduleName);
|
req.$target.data('icingaModule', moduleName);
|
||||||
classes.push('icinga-module');
|
classes.push('icinga-module');
|
||||||
|
@ -1025,13 +1023,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
req.$target.find('.container').each(function () {
|
|
||||||
// Lazy load module javascript (Applies only to module.js code)
|
// Lazy load module javascript (Applies only to module.js code)
|
||||||
var moduleName = $(this).data('icingaModule');
|
this.icinga.ensureSubModules(req.$target);
|
||||||
if (_this.icinga.hasModule(moduleName) && ! _this.icinga.isLoadedModule(moduleName)) {
|
|
||||||
_this.icinga.loadModule(moduleName);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
req.$target.find('.container').each(function () {
|
||||||
$(this).trigger('rendered', [req.autorefresh, req.scripted, req.autosubmit]);
|
$(this).trigger('rendered', [req.autorefresh, req.scripted, req.autosubmit]);
|
||||||
});
|
});
|
||||||
req.$target.trigger('rendered', [req.autorefresh, req.scripted, req.autosubmit]);
|
req.$target.trigger('rendered', [req.autorefresh, req.scripted, req.autosubmit]);
|
||||||
|
|
Loading…
Reference in New Issue