Hi Jorge,
If I've got right what you are trying to do, I think you can do
something like this:
on your master.kid
<body py:match="item.tag=='{http://www.w3.org/1999/xhtml}body'"
py:attrs="func">
If you put it inside the template that extends master.kid it wouldn't
work, that's something to look at probably.
on your controller:
if ... :
func = {"onload":"js_function(this.form['some_widget'])"}
else:
func = {"onload":None} (or even {})
return dict(func = func)
Here is working right.
Maybe it could work even with (can't test ATM):
<body py:match="item.tag=='{http://www.w3.org/1999/xhtml}body'"
py:if="variable"
py:attrs="{"onload":"js_function(this.form['some_widget'])"}">
if ... :
variable = True
else:
variable = False
return dict(func = func)
Ciao
Michele
Jorge Godoy wrote:
> Hi!
>
>
> How can I call a javascript funcion on page load when a given python variable
> is set? I tried:
>
> <body py:if="not variable">
> <body py:if="variable" onload="js_function(this.form['some_widget'])">
> ...
> </body>
>
> Then Kid complained when I immediately closed </html>. Adding a second
> "</body>" fixed this... BUT, the content doesn't appear.
>
> Is there any way to either pass the variable to a JS function (please, note
> the use of both " and ' what makes it difficult to use py:attrs...) or to
> just insert the onload when the condition is true?
>
>
> TIA,
> --
> Jorge Godoy <[EMAIL PROTECTED]>