[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:
@@ -73,10 +73,15 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function replaceElement(template) {
|
function addElement() {
|
||||||
|
if (activeElement !== element) {
|
||||||
activeElement.replaceWith(element);
|
activeElement.replaceWith(element);
|
||||||
activeElement = element;
|
activeElement = element;
|
||||||
activeElement.empty();
|
activeElement.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function populateElement(template) {
|
||||||
template(scope, function (innerClone) {
|
template(scope, function (innerClone) {
|
||||||
element.append(innerClone);
|
element.append(innerClone);
|
||||||
});
|
});
|
||||||
@@ -84,7 +89,7 @@ define(
|
|||||||
|
|
||||||
function applyTemplate(template) {
|
function applyTemplate(template) {
|
||||||
if (template) {
|
if (template) {
|
||||||
replaceElement(template);
|
populateElement(template);
|
||||||
} else {
|
} else {
|
||||||
removeElement();
|
removeElement();
|
||||||
}
|
}
|
||||||
@@ -93,6 +98,7 @@ define(
|
|||||||
function changeTemplate(templateUrl) {
|
function changeTemplate(templateUrl) {
|
||||||
if (templateUrl !== activeTemplateUrl) {
|
if (templateUrl !== activeTemplateUrl) {
|
||||||
if (templateUrl) {
|
if (templateUrl) {
|
||||||
|
addElement();
|
||||||
self.load(templateUrl).then(applyTemplate);
|
self.load(templateUrl).then(applyTemplate);
|
||||||
} else {
|
} else {
|
||||||
removeElement();
|
removeElement();
|
||||||
|
|||||||
Reference in New Issue
Block a user