Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Periodic JQuery update in Seaside

I am using Seaside (2.8 in Squeak 4.2) and am normally updating like this:

html div 
    onClick: ((html jQuery: '#asdf') load html: [:h|h text: 'qwer'])
    ; with: 'asdf'.

But this time, i have to update a div periodically.

I have used PT's periodicalEvaluator in another project, however in this one I can not, I have to stick to JQ.

I tried to use JQInstance's delay:millis in all combinations i could think of:

onClick: (((html jQuery id: 'chattertext') delay: 1000; yourself) load html: [:h| self renderTextOn: h])
; onClick: (((html jQuery id: 'chattertext') delay: 1000) load html: [:h| self renderTextOn: h])
; onClick: (((html jQuery id: 'chattertext') delay: 1000; load) html: [:h| self renderTextOn: h])
and others

for some reason the update is instantaneous instead of after 1000 millis which i need.

like image 464
ben Avatar asked Mar 24 '13 17:03

ben


2 Answers

Have a look at the example coming with the JQuery functional test suite:

JQRepeatingFunctionalTest>>#renderContentOn: html
  html paragraph
    script: (html jQuery this load
      html: [ :r | self renderTimeOn: r ];
      interval: 1 seconds); 
  with: [ self renderTimeOn: html ]

The example is running here.

like image 147
Lukas Renggli Avatar answered Oct 28 '22 02:10

Lukas Renggli


jQuery's delay function only applies to effects [1].

To achieve what you want, just use Javascript's setTimeout or setInterval functions:

onClick: (((html jQuery id: 'chattertext') load html: [:h| self renderTextOn: h]) timeout: 1000)

[1] http://api.jquery.com/delay/

like image 1
Johan B Avatar answered Oct 28 '22 02:10

Johan B