Search code examples
jquerysmalltalkseaside

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.


Solution

  • 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.