0

I'm trying to change the page programatically. This first line of code is working, but I don't need it to be delayed, so I tried the second line, but it's not working. What am I missing?

Working (but I don't want the delay):

setTimeout(function () {
    $(':mobile-pagecontainer').pagecontainer('change', '#pageId', { changeHash: false });
}, 1000);

Not working:

$(':mobile-pagecontainer').pagecontainer('change', '#pageId', { changeHash: false });

I'm calling it in the <head> of the document, nested in a "web app tester":

<script type="text/javascript">
if (("standalone" in window.navigator) && !window.navigator.standalone){
    //is standalone capable, but not in standalone mode
} else if (("standalone" in window.navigator) && window.navigator.standalone){ 
    //is standalone capable, in standalone mode
} else {
    //standalone mode not supported, ie. Desktop.

    //doesnt work:
    $(':mobile-pagecontainer').pagecontainer('change', '#pageId', { changeHash: false });

    //does work, but I don't want the delay:
    setTimeout(function () {
        $(':mobile-pagecontainer').pagecontainer('change', '#pageId', { changeHash: false });
    }, 1000);

}
</script>
Brad
  • 1,019
  • 1
  • 9
  • 22

1 Answers1

0

It code will works. Please check .

$(document).$(':mobile-pagecontainer').pagecontainer('change', '#pageId', { changeHash: false });
Elangovan
  • 3,469
  • 4
  • 31
  • 38
  • This didn't work. I tried it as suggested, as well as `$(document).(':mobile-pagecontainer').pagecontainer('change', '#pageId', { changeHash: false });` and `$(document).pagecontainer('change', '#pageId', { changeHash: false });` – Brad Sep 20 '16 at 10:20