Hello
Sorry to bother you all again with the same stuff. I'm trying to change the way i solve this kind of problem from the "hack" solution: posted here: http://www.nabble.com/Ajax-live-updates-tf1922480.html#a5263907 http://www.nabble.com/Displaying-progress-on-a-web-page-tf2115321.html#a5853986 http://www.nabble.com/Never-ending-poll-when-rendering-periodical-tf4011797.html to the solution Lukas proposed in: http://www.nabble.com/Never-ending-poll-when-rendering-periodical-tf4011797.html (second post, chronologically) which is the one using #stop and #assignTo: Consider this example: renderContentOn: html html div id: 'time'. html submitButton onClick: (html periodical id: 'time'; frequency: 1 second; assignTo: 'periodical'; callback: [ :r | r render: (DateAndTime now - (start ifNil: [ start := DateAndTime now ])) ]); text: 'Start'. html submitButton onClick: (html periodical alias: 'periodical'; call: 'stop'); text: 'Stop' As espected, the periodical works and whenerver the second button is clicked, it stops, everything is Ok. But now i need to stop the periodical as a result of the evaluation of a condition in the callback of the periodical, this is server side. Basically the periodical must stop itself when a certain condition is fulfilled. The problem is that such condition is checked server side and I can't find the way to execute the necessary javascript code client side, this would be something like this: renderContentOn: html html div id: 'time'. html submitButton onClick: (html periodical id: 'time'; frequency: 1 second; assignTo: 'periodical'; callback: [ :r | aCondition ifTrue:[ (r periodical) alias: 'periodical'; call: 'stop']]); text: 'Start'. But This does not work Any Ideas? Thanks again Leandro |
> html submitButton
> onClick: (html periodical > id: 'time'; > frequency: 1 second; > assignTo: 'periodical'; > callback: [ :r | aCondition ifTrue:[ > (r periodical) > alias: 'periodical'; > call: 'stop']]); > text: 'Start'. Have a look at the response you get in FireBug. There is no Javascript included. You need to somehow add it to the response, for example by writing: r script: (r periodical alias: 'periodical'; call: 'stop') Also note that if you are on an old version of Scriptaculous scripts of AJAX requests are not evaluated automatically. This means that you maybe have to set #evalScripts: to true on the outer updater. Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Lukas the response i get has, as you said, no javascript included. It's too long to be included here.. as for this, I've already tried it rendering the same you wrote, and setting #evalScripts: to true. The response contains javascript but still does not work: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xml:lang="en" xmlns="http://www.w3.org /1999/xhtml" lang="en"><head><title>Seaside</title><meta content="text/html; charset=utf-8" http-equiv ="Content-Type" /></head><body><script type="text/javascript">/*<![CDATA[*/periodical.stop()/*]]>*/</script > nothing happens, the periodical doesn't stop. I've also tried to do some more weird stuff, like rendering a hidden div with a onLoad javascript event that stops the periodical... and again nothing happens.. It's so frustrating!! |
Does it stop if you run the code in the console?
-Boris -- +1.604.689.0322 DeepCove Labs Ltd. 4th floor 595 Howe Street Vancouver, Canada V6C 2T5 http://tinyurl.com/r7uw4 [hidden email] CONFIDENTIALITY NOTICE This email is intended only for the persons named in the message header. Unless otherwise indicated, it contains information that is private and confidential. If you have received it in error, please notify the sender and delete the entire message including any attachments. Thank you. > -----Original Message----- > From: [hidden email] [mailto:seaside- > [hidden email]] On Behalf Of Leandro Pérez > Sent: Thursday, July 05, 2007 9:09 AM > To: [hidden email] > Subject: Re: [Seaside] How to stop periodical, end a polling mechanism... > again > > > > Lukas Renggli wrote: > > > > > > Have a look at the response you get in FireBug. There is no Javascript > > included. You need to somehow add it to the response, for example by > > writing: > > > Lukas the response i get has, as you said, no javascript included. It's > too > long to be included here.. > > > Lukas Renggli wrote: > > > > You need to somehow add it to the response, for example by > > writing: > > r script: (r periodical alias: 'periodical'; call: 'stop') > > > > Also note that if you are on an old version of Scriptaculous scripts > > of AJAX requests are not evaluated automatically. This means that you > > maybe have to set #evalScripts: to true on the outer updater. > > > > Lukas > > > > as for this, > I've already tried it rendering the same you wrote, and setting > #evalScripts: to true. The response contains javascript but still does not > work: > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html > xml:lang="en" xmlns="http://www.w3.org > > /1999/xhtml" lang="en"><head><title>Seaside</title><meta > content="text/html; > charset=utf-8" http-equiv > > ="Content-Type" /></head><body><script > type="text/javascript">/*<![CDATA[*/periodical.stop()/*]]>*/</script > > > > > nothing happens, the periodical doesn't stop. > I've also tried to do some more weird stuff, like rendering a hidden div > with a onLoad javascript event > that stops the periodical... > and again nothing happens.. > It's so frustrating!! > -- > View this message in context: http://www.nabble.com/How-to-stop- > periodical%2C-end-a-polling-mechanism...-again-tf4030323.html#a11449597 > Sent from the Squeak - Seaside mailing list archive at Nabble.com. > > _______________________________________________ > Seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Mmm.. I wouldn't know how to do that, should I create a script and "Do It" or something like that¿? Honestly I have no idea |
In reply to this post by Leandro Pérez
> I've already tried it rendering the same you wrote, and setting
> #evalScripts: to true. The response contains javascript but still does not > work: > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html > xml:lang="en" xmlns="http://www.w3.org > > /1999/xhtml" lang="en"><head><title>Seaside</title><meta content="text/html; > charset=utf-8" http-equiv > > ="Content-Type" /></head><body><script > type="text/javascript">/*<![CDATA[*/periodical.stop()/*]]>*/</script > > nothing happens, the periodical doesn't stop. > I've also tried to do some more weird stuff, like rendering a hidden div > with a onLoad javascript event > that stops the periodical... > and again nothing happens.. > It's so frustrating!! I copy and pasted your example. I fixed it according to my previous mail and it works. As a response you should only get: <script type="text/javascript">/*<![CDATA[*/periodical.stop()/*]]>*/</script> Nothing else, especially no <head> and <body> tags. Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
I have followed your thread which is quite interesting.
I have successfully followed the advices Lukas provided. It's so amazing when it works !!! Indeed, no <head> and <body> tags in the response. But I had both of these tags due to the #evalScripts: not at the right place. As Lukas suggested, I am on an older version of Scriptaculous and I needed #evalScripts: set to true but on the OUTER updater. Here is the code: html div id: 'time'. (html submitButton) onClick: ((html periodical) id: 'time'; evalScripts: true; frequency: 1 second; assignTo: 'periodical'; callback: [:r | (DateAndTime now - (start ifNil: [start := DateAndTime now])) seconds > 10 "#sample criteria#" ifTrue: [r script: ((r periodical) alias: 'periodical'; "evalScripts: true; should not be there according to Lukas' advise" call: 'stop'). start := nil] ifFalse: [r render: DateAndTime now - start]]); text: 'Start'. LukasThank you Folks, Julien _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
thanks to both of you Lukas and Julien, right now I'm not at work and can't access my vw image, i should consider seriously bringing it back to my home.. :) anyway, as soon as i get back to work i'll try that and I will post how everything turned out, hopefully ok! Regards Leandro |
Ok, I've just pinpointed what my problem was, I'll try to explain what i've found, but I have to say that I don't completely understand what is going on or why.. so, if anyone can explain the reasons it would be very nice!
The next few lines work ok, renderContentOn: html html div id: 'myDiv'. (html submitButton) id: 'button'; onClick: (html evaluator callback: [:script | [working:= true. (Delay forSeconds: 5) wait. "simulate the long running process" working:= false] fork]); onClick: ((html periodical) id: 'myDiv'; frequency: 1 second; assignTo: 'periodical'; callback: [:r | working ifFalse: [r script: ((r element) alias: 'periodical'; call: 'stop')]]); text: 'Work!' This renders a submit button that, when clicked, triggers a long running process server side, and a periodical updater client side. The idea is that the periodical will poll to the server every 1 second until the long running process is finished, then, a script is rendered that stops the client side periodical updater. This could be used to display a work in progress image or something like that.. My problem was that I wasn't giving an id to the periodical, or that such id didn't match any other element's id. In any case, the periodical polled forever.. Example n.1: this example bellow does not work as it is meant to. The periodical never stops polling... renderContentOn: html "Note that the div with id=myDiv is missing here!" (html submitButton) id: 'button'; onClick: (html evaluator callback: [:script | [working:= true. (Delay forSeconds: 5) wait. "simulate the long running process" working:= false] fork]); onClick: ((html periodical) id: 'myDiv'; frequency: 1 second; assignTo: 'periodical'; callback: [:r | working ifFalse: [r script: ((r element) alias: 'periodical'; call: 'stop')]]); text: 'Work!' Could it be because the rendered script is not associated to any element??? no idea Example n.2: no id is given to the periodical, it does not work either. renderContentOn: html html div id: 'myDiv'. (html submitButton) id: 'button'; onClick: (html evaluator callback: [:script | [working:= true. (Delay forSeconds: 5) wait. "simulate the long running process" working:= false] fork]); onClick: ((html periodical) "This line is a comment id: 'myDiv';" frequency: 1 second; assignTo: 'periodical'; callback: [:r | working ifFalse: [r script: ((r element) alias: 'periodical'; call: 'stop')]]); text: 'Work!' The results here are even stranger, the periodical stops polling but inside the submit button some sort of a nested input field is rendered (at least in firefox).. very weird.. Well, I hope anyone has some answers to clarify my mind, and that this will be usefull to somebody Regards Leandro --- VisualWorks nc.7.5 Seaside (2.8a1.399) SeasideScriptaculous (2.8a1.205.0,mbany) |
Free forum by Nabble | Edit this page |