mirror of
https://github.com/nasa/openmct.git
synced 2025-04-23 02:13:52 +00:00
[Representation] Show element synchronously
...to avoid exceptions when trying to invoke representers before an mct-representation has been added back into the DOM.
This commit is contained in:
parent
bcc42d705e
commit
5677548298
@ -73,10 +73,15 @@ define(
|
||||
}
|
||||
}
|
||||
|
||||
function replaceElement(template) {
|
||||
activeElement.replaceWith(element);
|
||||
activeElement = element;
|
||||
activeElement.empty();
|
||||
function addElement() {
|
||||
if (activeElement !== element) {
|
||||
activeElement.replaceWith(element);
|
||||
activeElement = element;
|
||||
activeElement.empty();
|
||||
}
|
||||
}
|
||||
|
||||
function populateElement(template) {
|
||||
template(scope, function (innerClone) {
|
||||
element.append(innerClone);
|
||||
});
|
||||
@ -84,7 +89,7 @@ define(
|
||||
|
||||
function applyTemplate(template) {
|
||||
if (template) {
|
||||
replaceElement(template);
|
||||
populateElement(template);
|
||||
} else {
|
||||
removeElement();
|
||||
}
|
||||
@ -93,6 +98,7 @@ define(
|
||||
function changeTemplate(templateUrl) {
|
||||
if (templateUrl !== activeTemplateUrl) {
|
||||
if (templateUrl) {
|
||||
addElement();
|
||||
self.load(templateUrl).then(applyTemplate);
|
||||
} else {
|
||||
removeElement();
|
||||
|
Loading…
x
Reference in New Issue
Block a user