On 10/5/07, onmountain <[EMAIL PROTECTED]> wrote:
>
>
> Hi. New to Turbogears and Mochikit (did I just hear everyone clicking
> the back key? :-)
> I am teaching myself by doing an in/out sign in board, which I have
> gotten to the point where I have a table that I can sort, as well as
> update by clicking on the edit button for the inout_status field.
> Really think TG and Mochikit are cool!!!!
> My stumbling point now is how to keep the table contents up-to-date
> (showing all the correct inout_status values as people update their
> own status) without doing a page refresh.
"without doing a page refresh" = ajax .
but maybe you already new that ;)
Is there a timer function
> (I think that calllater might be it???).
yes, you can use the callLater function,
especially for idea #2, see below.
I have two ideas here:
>
> 1) Have TG maintain a variable (change_flag) that the edit button(s)
> on all the user screens will set as TRUE when the user changes
> inout_status. Each screen could then periodically check for that
> change_flag == true, and if so, the table value could all be updated?
>
> 2) Just have a timer in Mochikit that would trigger periodic updates
> to ALL the table contents.
maybe something like this:
var REFRESH_INTERVAL = 120; //120 seconds, every 2 minutes.
//Warning: dont make interval to short,or you will have unhappy browsers
var updateTableWithNewData = function(res){
//'res" is the data from an ajax query for your table data
// insert new data in table logic here *See MochiKit.DOM*
}
var getNewTableData = function(url){
//url is the /path/that/serves/new/tabledata
d = loadJSONDoc(url); //could be 'doXHR' or similar
d.addCallback(updateTableWithNewData);
}
callLater(REFRESH_INTERVAL, getNewTableData);
You will need to start the 'refresh loop' with some 'onload' function as
well.
Hope this helps.
Alex
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---