Making javascript with ZPT variables
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
Hm I think IE and Konq might be missing the ';'s after the variable definition in the first script Anyway this looks like a client issue; browsers really *should* see the vars from the first script hth peter. Lennart Regebro wrote:
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
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Peter Sabaini wrote:
Hm I think IE and Konq might be missing the ';'s after the variable definition in the first script
Nope, that wasn't it at all. It was a small comma they didn't like. Thanks for telling me that it SHOULD work. :) It made me look harder.
participants (2)
-
Lennart Regebro -
Peter Sabaini