Sometimes we're making Content Apps that load data from other sources.
We do this in the constructor of the angular controller.
The problem is that the controller is initalised even if the Content App is not used. So it takes time to load the Content App when opening the document node even if the Content App is not clicked.
Is there a way to make this event-driven? So that an event is invoked when the Content App is selected?
We now do it like this but it is not very elegant:
$('button.umb-sub-views-nav-item__action').on('click', function (e) {
var apps = editorState.current.variants[0].apps;
$.each(apps, function (appid) {
if (apps[appid].alias == "OurAppAlias") {
vm.versionIsActive = apps[appid].active;
};
});
if (vm.versionIsActive) {
onInit()
}
});
Content App events?
Hi,
Sometimes we're making Content Apps that load data from other sources. We do this in the constructor of the angular controller. The problem is that the controller is initalised even if the Content App is not used. So it takes time to load the Content App when opening the document node even if the Content App is not clicked.
Is there a way to make this event-driven? So that an event is invoked when the Content App is selected? We now do it like this but it is not very elegant:
Is there a better way to do this?
iNETZO
Hi,
yes, just had to do this yesterday!
you can listen for the
app.tabChange
event, which is triggered when the user swiches between content apps.so you can do a similar thing you what you have, but only run when your 'tab' is active.
e.g i have this (where vm.initialized is my variable to make sure we only do it once)
Hi Kevin,
Thank you very much for sharing your solution! This is indeed much cleaner way.
Best regards,
iNETZO
is working on a reply...