Re: how to stopInterval which was created by JSObject>>interval:

"Esteban A. Maringolo" <[email protected]>
Newsgroups gmane.comp.lang.smalltalk.squeak.seaside
Message-ID <CAJMgPCKA419-D_PtXq=_H=NKNL8KLq=qefUO3cwdGV_=vO2Fjg@mail.gmail.com>
Every time you call setInterval() or setTimeout() it returns its
internal ID of the newly created interval/timeout.

To stop it  you should call window.clearInterval(intervalId).

I guess you could do it by assigning the function to a variable like



html div
...
script:
  (
    (html jQuery id: anId) load
       html: [ :r | ...show the report file... ];
       interval: 2 seconds) assignTo: 'myVariable' ).


And in other event handler you call:
html anchor
  jsUrl;
  onClick: (JSStream on: 'window.clearInterval("myVariable"));
  with: 'Stop interval'.

Code not tested on my computer, but that should give a hint of where to look at.

Regards.

Esteban A. Maringolo


2017-04-25 6:21 GMT-03:00 Sabine Manaa <[email protected]>:
> Hi,
>
> 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 load
> I want to call clearInterval() with this timerId.
> html div
> ...
> script:
> ((html jQuery id: anId) load
> html: [ :r |
> ...show the report file... ];
> interval: 2 seconds);
>
> It creates this JS
>
> setInterval(function(){$("#imageVehicleReport").load("/RKA",["_s=sW0fUJ73IwxSs_bo","_k=b14htm7FJ6AWvWeW","4152"].join("&"))},2000)
>
> How can I stop it?
>
> Regards
> Sabine
>
> _______________________________________________
> seaside mailing list
> [email protected]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
_______________________________________________
seaside mailing list
[email protected]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.