Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Vaadin 7 alpha3 - JavaScript

Artur Signell
9 years ago Jun 29, 2012 8:07pm
Michel Klein
9 years ago Oct 08, 2012 8:51am
Leif Åstrand
9 years ago Oct 08, 2012 3:04pm

Your problem is caused because setInterval is evaling "setTime()" in the global scope whereas the function is only defined in the local scope where the script is evaluated.

The best workaround to this is to pass the function directly to setInterval instead of passing a string that is evaluated by the javascript engine. This is done by changing your last row to pass the setTime function instead of a string containing the name of the function.

script.append("setInterval(setTime, 1000);");
Last updated on Oct, 8th 2012
Michel Klein
9 years ago Oct 09, 2012 6:31am
Kunal Patil
8 years ago Feb 25, 2014 11:17am
Burke Ingraffia
6 years ago Dec 23, 2015 7:04pm