Error Undefined function [Javascript]


  • Hi,I have a problem whit a script like this:

    #some code classic
    <input id="bt" type="button"; value="press";/>
    #some code classic

    the problem is onjavascript:

    Home.js (function () { "use strict"; WinJS.UI.Pages.define("/pages/home/home.html", { ready: function (element, options) { var test1 = document.getElementById("bt"); test1.addEventListener("click", Test, false); } }); function Test() { //some code window.setTimeout("Test_2()", 150); }

    //the error is here, he says that there is no function Test_2

    function Test_2() { //some code } })();

    Wednesday, July 24, 2013 11:07 PM


  • The first argument to setTimeout is a function object, not a string. Just say setTimeout(Test_2, 150) and it should work. Don't do Test2() because that makes the first argument the return value from Test_2 instead, which would only work if that function was itself returning another function.
    Thursday, July 25, 2013 12:22 AM