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?

+3


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



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)

+7


source


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?

0


source


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

WinJS.UI.processAll();
appBar.winControl.show();

      

Html

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

      

0


source







All Articles