How to show WinJS AppBar on page fragment load?
I want to show the AppBar when a page fragment is loaded, but this code, run in the ready function, does not work as expected:
function ready(element, options) {
var appBar = document.getElementById("appBar").winControl;
appBar.disabled = false;
appBar.show();
}
How to show AppBar on page fragment load?
source to share
Assuming you are creating the app bar correctly in your HTML file.
Then in the method ready
you must first call
WinJS.UI.processAll(elements)
.then(function () {
var appbar = document.getElementById("appBar");
if (appbar) {
appbar.winControl.show();
}
});
As per the MSDN documentation, the function processAll
"applies declarative control that binds all elements starting from the specified root element." (i.e. turning the entire html element into WinJS controls)
source to share
I've tried the following piece of code:
document.getElementById("appBar").winControl.show()
And it works as expected (application bar is shown on page load).
The same is also used in the msdn example: Application bar example
It seems that you have another problem (incorrect controls in the app bar or whatever).
Could you provide more details or even a sample application?
source to share