[Zope] How do you replace content with an action?
Jonathan Hobbs
toolkit at magma.ca
Sat Sep 4 08:57:44 EDT 2004
From: "robert rottermann" <robert at redcor.ch>
To: "Laura McCord" <Laura.McCord at doucet-austin.com>
> Laura,
>
> as somebody else told you in an other thread, you must be careful to
> distinguish between what happens on the server and and what on the client.
> Zope and it's tools work solely on the the server, java script only on
> the server.
> Tal templates work on the server to prepare a html page that zoope will
> send to your client. Once it is there your java script can deal with it.
>
> This two phases are run in total isolation and neither of the two is
> avare of the other. Furthermore, there is no easy way for the two, to
> communicate.
I haven't been paying too much attention to this thread, but the comment
'there is no easy way for the two to communicate' caught my attention.
You can set up, quite easily, a way for your client-side javascript to
communicate with the server-side zope which is invisible (well, to the
non-technical) to the end-user.
Start by creating a hidden iframe in your html page (call this 'Page 1').
Set the initial url to be loaded to point to a method on the zope server.
The method on the zope server does some action (ie. a db lookup) and assigns
the results to javascript variables; the key piece is to have some html in
the method which has a javascript 'onload' command which invokes a
javascript function (which is defined in the code for 'Page 1'); this js
function does something with the js variables that were created by the zope
method and modifies the display on 'Page 1'.
Very kewl way to load a single page and then keep it updated with info from
the server (ie. you can use js to keep loading zope methods into the iframe
and then handle the returned data)!
HTH
Jonathan
More information about the Zope
mailing list