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;;


How to show AppBar on page fragment load?


source to share

3 answers

Assuming you are creating the app bar correctly in your HTML file.

Then in the method ready

you must first call

        .then(function () {
              var appbar = document.getElementById("appBar");
              if (appbar) {


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)



I've tried the following piece of code:



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?



If you get a null error call WinJS.UI.processAll () in your initialization code.




<div id="appBar" data-win-control="WinJS.UI.AppBar" data-win-options="{placement:'bottom'}">




All Articles