0

I have this simple js in velocity jira template. I need to sleep function and call function test but its not called at all. Can you elaborate into this issue why its not happening? issueNumber is velocity variable.

    <script>
    function test() {
        var get = $issueNumber;
        alert(get);
    }
    setTimeout(test, 5000);
    test();
    </script>
jira jira
  • 17
  • 6
  • Hi there. You are trying to call test twice. Are you saying that the immediate call succeeds and the delayed call doesn't? – rand'Chris May 02 '20 at 15:52
  • I am not getting alert on screen. setTimeout is not only setting but also calling function? – jira jira May 02 '20 at 15:53
  • I don't understand your response. setTimeout should call the function after 5000ms, it doesn't "set" anything. There is an answer below you can accept if it works. I don't know how Jira works, but setTimeout is going to change the execution context of "test". You can pass arguments to test() by giving them after the timeout delay value. If this helps I will re-post as an answer. – rand'Chris May 02 '20 at 16:02

1 Answers1

0

Remove the call of test, the test function will be executed after 5 seconds as excepted.

function test() {
   var get = 2;
   alert(get);
}
    
setTimeout(test, 5000);
A. Ecrubit
  • 561
  • 6
  • 20