locked
Resume Behavior with "Getting started with HTML5 and JavaScript for Windows Phone Store sample"

    Question

  • Hello,

    I am running into a bug when running the following sample whether it is on the emulator or a device

    https://code.msdn.microsoft.com/windowsapps/Getting-started-with-HTML5-3d8e1aac

    1) Build and deploy
    2) Application runs and behaves without any issues (i.e. say hello is working)
    3) Press Back to go to the start screen
    4) Load the app again from the start screen or the app list (not from VS)
    5) Try the say hello button and it doesn't do anything

    It looks like something is not wired correctly. The funny thing is that when the debugger is attached, I can the execution going into the ready function where all the wiring is done.

    Have anyone encounter this issue or know how to fix it?

    Thanks!


    Jonathan Co

    Wednesday, March 11, 2015 12:49 PM

All replies

  • Hi Jonathan,

    I can repro your issue with the third sample in the package.

    Here I did a really simple test, I wrote following code in html to see if the app functions well.

                <button id="helloButton" onclick="btclick()">Say "Hello"</button>
                <div id="greetingOutput"></div>
                <div id="greetingOutput1"></div>
    
        <script>
            function btclick()
            {
                var userName = document.getElementById("nameInput").value;
                var greetingString = "Hello, " + userName + "!";
                document.getElementById("greetingOutput1").innerText = greetingString;
            }
        </script>


    I can see that when we back to the app from the app list, the greetingOutput1 works fine, that means the JavaScript code executed as expected. In another word, the js behind the page which is home.js does not successfully add event to the button click when the app resumes.

                var helloButton = document.getElementById("helloButton");
                helloButton.addEventListener("click", this.buttonClickHandler, false);

    As a quick walk around I may suggest you statically write the code as I did, but this could not be a best practice, I'm still trying to find out if we have a better solution for you.

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, March 12, 2015 5:28 AM
    Moderator
  • I'll try to statically write the code but if you find a better solution, please let me know.

    Thanks!


    Jonathan Co

    Thursday, March 12, 2015 9:33 PM