Question
Can I automatically open a top nav app?
Answer
You can open a top nav when the app is first loaded however you cannot do this directly from a top nav app. Top nav apps are not loaded into the DOM and therefore available to make requests until they are first opened. For more information, see this page: preloadPane.
To workaround this, make this request from an app in another location using the instances API (ticket sidebar, side nav, or ideally a background app). For example, have the app locations set to both top_bar
and background in your manifest:
"location": {
"support": {
"background": "assets/iframe.html",
"top_bar": "assets/iframe.html"
}
Because the app is configured to also be in the background location which loads immediately, you are then able to use the background app and the instances API to pop open the top nav app automatically.
var client = ZAFClient.init();
var topBarClientPromise = client.get('instances').then(function(instancesData) {
var instances = instancesData.instances;
for (var instanceGuid in instances) {
if (instances[instanceGuid].location === 'top_bar') {
return client.instance(instanceGuid);
}
}
});
topBarClientPromise.then(function(topBarClient) {
// opens the top bar app, even if its iframe hasn't been loaded
topBarClient.invoke('popover');
});
For more information, see the article: Messaging between locations.
2 comments
Kumar B
How do I just load the top_bar, not open,
So when I actual want to open, I can run this code inside the top_bar itself.
0
Greg Katechis
Hi Kumar! In that situation, you should be able to use `preloadPane` to get what you need!
1