[Seaside] how to stopInterval which was created by JSObject>>interval:
pdebruic at gmail.com
Tue Apr 25 14:28:32 UTC 2017
JSObject has #assignTo: which you can use to assign the interval id returned
by the setInterval() js function to a js var name in the browser. So in
your case I might try
(((html jQuery id: anId) load
html: [ :r |
...show the report file... ];
interval: 2 seconds) assignTo: 'interval',anId
Then later you can clear the interval.
Another strategy is to use your polling code to set a #timeout: rather than
the #interval:. So the polling code checks to see if the report is ready,
if not it sets another timeout to check again in two seconds.
When the report is ready, it returns the report. In that way the
interval/timeout mess cleans up after itself.
Sabine Manaa wrote
> I use JSObject>>interval: (thanks Johan) for my report generation:
> first I show a spinner. Every 2 seconds, I try to reload the reports png
> file (it takes a little time to generate it).
> This works but I have one final problem: how can I stop the interval?
> Four intervals are started each time the user selects a trip and wants the
> reports to be shown (there are 4 report types currently). I have to stop
> them, if not, they overlap with the old reports.
> Below is a part of the code I use. As far as I understand, I need an ID of
> the interval to call clearInterval(timerId); In the onComplete: of the
> I want to call clearInterval() with this timerId.
> html div
> ((html jQuery id: anId) load
> html: [ :r |
> ...show the report file... ];
> interval: 2 seconds);
> It creates this JS
> How can I stop it?
> seaside mailing list
> seaside at .squeakfoundation
View this message in context: http://forum.world.st/how-to-stopInterval-which-was-created-by-JSObject-interval-tp4943993p4944038.html
Sent from the Seaside General mailing list archive at Nabble.com.
More information about the seaside