[Zope] Making javascript with ZPT variables

Lennart Regebro lennart at regebro.nu
Fri Nov 7 08:33:00 EST 2003


I'm sure this is FAQ, but I can't really find anything conclusive.

I have a ZPT page, in which I have quite a bit of javascript, in which I 
need ZPT variables. So far I have done this:

  <script language="JavaScript" type="text/javascript"
     tal:content='structure string:
      var thisurl = "${here/absolute_url}"
      var search_fields = ${data/js_search_fields}
      var role = "${data/role}"
      var method = "${data/method}"
   '>
   </script>

   <script language="JavaScript" type="text/javascript"
     tal:content="structure python: here.pylist2js('owners', owners)">
   </script>

   <script language="JavaScript" type="text/javascript">

	here is the actual javascript code....

   </script>


Now this doesn't work in IE, (or Konqueror) and that is because the 
variables defined in the first piece of javascript is not propagated to 
the later javascripts. It works fine in Mozilla, by the way.

So, I need to define one BUG javascript, that not only defines the 
codes, but also the variables. The problem here is mainly ho I can get 
the code, which is text, together with the lists, that need python code 
for the conversion.

How do you people to it?

//Lennart




More information about the Zope mailing list