2013-03-24 9 views
5

sto usando al mare (2,8 in Squeak 4.2) e sto normalmente aggiornando in questo modo:periodico aggiornamento JQuery a Seaside

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

Ma questa volta, devo aggiornamento un div periodicamente.

Ho usato PT periodicalEvaluator in un altro progetto, tuttavia in questo non posso, devo attenermi a JQ.

Ho cercato di utilizzare di JQInstance delay:millis in tutte le combinazioni i potrebbe pensare di:

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 

per qualche motivo l'aggiornamento è istantaneo anziché dopo 1000 millis che ho bisogno.

risposta

4

Dai un'occhiata alla all'esempio che viene con la suite di test funzionale JQuery:

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

L'esempio è in esecuzione here.

+0

Ecco, grazie! Non posso ancora fare +1 perché richiede 15 rappresentanti. – ben

+0

non l'ho dimenticato ;-) – ben

1

La funzione di jQuery delay si applica solo agli effetti [1].

per ottenere quello che vuoi, basta usare setTimeout del Javascript o funzioni setInterval:

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

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

+0

Innanzitutto, grazie per la risposta. Ma mostra un errore: 'WAError: l'opzione 'timeout' non è supportata in JQLoad. Utilizza #ajaxSetup per configurare i valori predefiniti o la versione più potente con # ajax. Qualche idea su come risolvere questo problema? – ben

+0

Questo è davvero uno sfortunato metodo di sovrascrittura sui wrapper JQAjax. Puoi provare il seguente? (((html jQuery id: 'chattertext') carica html: [: h | self renderTextText: h]) addDecoration: (Durata JSTimeout: aDuration)) Fammi sapere se funziona, quindi adatterò la mia risposta. –

+0

ah vedo, è stato risolto nel frattempo :-) –

Problemi correlati