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
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
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
seaside@.squeakfoundation
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
-- View this message in context: http://forum.world.st/how-to-stopInterval-which-was-created-by-JSObject-inte... Sent from the Seaside General mailing list archive at Nabble.com.
Hi Paul and Esteban,
thanks a lot for your answer. I just managed it to create my reports with the >>assignTo: hint.
I needed an additional js which starts in onComplete: of the load and also has an interval. this interval watches if the report is rendered and if yes, stops himself and the report creator interval. It took some time for me to understand and find a good way but now I am happy with this solution.
Before, I had a complete javascript only solution and this was more complicated and did not work sometimes.
Regards Sabine
2017-04-25 16:28 GMT+02:00 Paul DeBruicker [via Smalltalk] < ml+s1294792n4944038h73@n4.nabble.com>:
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 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 [hidden email] http:///user/SendEmail.jtp?type=node&node=4944038&i=0 http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
If you reply to this email, your message will be added to the discussion below: http://forum.world.st/how-to-stopInterval-which-was- created-by-JSObject-interval-tp4943993p4944038.html To start a new topic under Seaside General, email ml+s1294792n86180h75@n4. nabble.com To unsubscribe from Seaside, click here http://forum.world.st/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1310907&code=bWFuYWEuc2FiaW5lQGdtYWlsLmNvbXwxMzEwOTA3fC0xOTE3OTcxOTg5 . NAML http://forum.world.st/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
-- View this message in context: http://forum.world.st/how-to-stopInterval-which-was-created-by-JSObject-inte... Sent from the Seaside General mailing list archive at Nabble.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 manaa.sabine@gmail.com:
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 seaside@lists.squeakfoundation.org http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
seaside@lists.squeakfoundation.org