Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Timer callback in Pharo smalltalk + Seaside

I've just ported my Dolphin Smalltalk + Seaside application to the latest Pharo Smalltalk 4.0 and Seaside 3.1. In it, I need a callback every second from the (browser) client to the (Pharo) server to update the view.

I had this piece of code to press the "Update" button automatically every second. But it does not work anymore after the port to Pharo:

html script: (
    ( html jQuery: '#updateButton' ) 
        call: 'click';
        interval: 1000 ).

I've searched the net for other (more elegant?) solutions but can't seem to get them to work. Can anybody give me a hint on how to proceed?

This is the JavaScript code that is generated by the code above and which used to work in Dolphin + Seaside:

<script type="text/javascript">
/*
<![CDATA[/setInterval(function(){$("#updateButton").cl‌​ick()},2000)/]]>
*/</script> 
like image 899
FunctionPoint Avatar asked Nov 29 '15 14:11

FunctionPoint


1 Answers

I suppose that the server callback is attached to the button with id #updateButton? It is odd that you have a script that triggers a click action on that button instead of triggering a callback every xx seconds.

The following script would update the entire body every 10 seconds. Given that you implement the right rendering methods, this is probably a more elegant solution:

html script: (
    ((html jQuery: 'body') load
        html: [ :innerHtml | self renderOn: innerHtml ]) 
            interval: 10000)
like image 118
Johan B Avatar answered Nov 08 '22 07:11

Johan B