Fix a bug in the component loader that caused components to be loaded multiple times

refs # 4456
This commit is contained in:
Matthias Jentsch 2013-08-20 19:09:07 +02:00 committed by Marius Hein
parent 61fad6b89c
commit 889abf55eb
1 changed files with 17 additions and 11 deletions

View File

@ -81,17 +81,23 @@ define(['jquery', 'logging', 'icinga/componentRegistry'], function ($, log, regi
.each(function(index, el) {
var type = $(el).attr('data-icinga-component');
pendingFns++;
loadComponent(
type,
el,
function(cmp) {
var id = registry.add(cmp, el.id, type);
registry.markActive(id);
el.id = id;
finalize();
},
finalize
);
if (!el.id || !registry.getById(el.id)) {
loadComponent(
type,
el,
function(cmp) {
var id = registry.add(cmp, el.id, type);
registry.markActive(id);
el.id = id;
finalize();
},
finalize
);
} else {
registry.markActive(el.id);
finalize();
}
});
finalize();
};