Make my button call the correct function


  • I can't seem to figure out where I made my probably obvious mistake. 


    <button id="yes" type="button">Yes</button>


    // For an introduction to the Page Control template, see the following documentation:
    // http://go.microsoft.com/fwlink/?LinkId=232511
    (function () {
        "use strict";
        function yesFunction()/*tried with and w/o parameter*/ {
            console.log("In function");
        WinJS.UI.Pages.define("/pages/yes.html", {
            ready: function (element, options) {
                var yesButton = document.getElementById("yes");
                yesButton.addEventListener("click", yesFunction, false);
            yesFunction: function (buttonClicked) /*tried with and without parameter*/ {
                console.log("In function");
    Neither of the yes functions, the one inside the ready() or outside the ready(), are sending the message to the console

    Monday, April 22, 2013 8:16 PM


  • Change :

    yesButton.addEventListener("click", yesFunction, false);


    yesButton.addEventListener("click", this.yesFunction.bind(this), false);

    Also remove the outer "yesFunction". Just keep the one within "ready" function.

    - Girija

    • Edited by Girija Beuria Monday, April 22, 2013 9:10 PM
    • Marked as answer by ZachAtttack Tuesday, April 23, 2013 2:53 PM
    Monday, April 22, 2013 9:05 PM