Pharo smalltalk + Seaside 中的定时器回调

Timer callback in Pharo smalltalk + Seaside

我刚刚将我的 Dolphin Smalltalk + Seaside 应用程序移植到最新的 Pharo Smalltalk 4.0 和 Seaside 3.1。在其中,我需要每秒从(浏览器)客户端回调到(Pharo)服务器以更新视图。

我有这段代码可以每秒自动按下 "Update" 按钮。但是在移植到 Pharo 之后它不再工作了:

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

我在网上搜索了其他(更优雅?)解决方案,但似乎无法让它们工作。有人可以提示我如何进行吗?

这是由上面的代码生成的 JavaScript 代码,用于在 Dolphin + Seaside 中工作:

<script type="text/javascript">
/*
<![CDATA[/setInterval(function(){$("#updateButton").cl‌​ick()},2000)/]]>
*/</script> 

我想服务器回调附加到 ID 为 #updateButton 的按钮?奇怪的是,您有一个脚本触发该按钮上的单击操作,而不是每 xx 秒触发一次回调。

以下脚本每 10 秒更新一次整个正文。如果您实现了正确的渲染方法,这可能是一个更优雅的解决方案:

html script: (
    ((html jQuery: 'body') load
        html: [ :innerHtml | self renderOn: innerHtml ]) 
            interval: 10000)