[TurboGears] Re: Using onload combined with py:if

2005-12-07 Thread Michele Cella
Jorge Godoy wrote: Interesting, Michele, because I haven't tried putting it in master.kid. Since it is something particular to this page only, I didn't think about putting it there and polluting the whole site. This is definitely something to look at. Specially because if I had something

[TurboGears] Re: Using onload combined with py:if

2005-12-07 Thread Jorge Godoy
Michele Cella [EMAIL PROTECTED] writes: In my case adding it to the template that extends master.kid does nothing, I always get: body I have the same problem here. That's not what I would expect, I haven't looked too close at master.kid but It can be a problem related to it. Mine says:

[TurboGears] Re: Using onload combined with py:if

2005-12-06 Thread Jeff Watkins
Jorge Godoy wrote: 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 I would probably address this like so: script py:if=variable

[TurboGears] Re: Using onload combined with py:if

2005-12-06 Thread Jared Kuolt
I looked up py:attrs to see if it is possible to do it the way you want, but it doesn't look like the py:if works for attributes inside elements. I would just change the variable from Boolean to the onload method: body onload=${jsonload} You could also have it perform the js task right before

[TurboGears] Re: Using onload combined with py:if

2005-12-06 Thread Jorge Godoy
Jeff Watkins [EMAIL PROTECTED] writes: I would probably address this like so: script py:if=variable type=text/javascript language=javascript function documentLoaded() { js_function(this.form['some_widget']); } if (window.addEventListener) window.addEventListener( load,

[TurboGears] Re: Using onload combined with py:if

2005-12-06 Thread Jared Kuolt
script py:if=True my_fun_method(); /script /body Though that somewhat defeats the purpose of onload. I want to run a JS function, not a Python function... This is part of the problem (the other part is that I don't know much JavaScript ;-)). This is javascript. Let me redo it

[TurboGears] Re: Using onload combined with py:if

2005-12-06 Thread Jeff Watkins
Jorge Godoy wrote: It didn't work also... I think the problem is that I'm not inside a form to use this.form... I'll play a bit with your code, Jeff, and I'll see what I can do. Well, I can't guarantee the quality of other people's code. I just copied this.form (etc) from your original

[TurboGears] Re: Using onload combined with py:if

2005-12-06 Thread Bob Ippolito
On Dec 6, 2005, at 12:48 PM, Jeff Watkins wrote: Jorge Godoy wrote: 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 I would probably

[TurboGears] Re: Using onload combined with py:if

2005-12-06 Thread Jorge Godoy
Jared Kuolt [EMAIL PROTECTED] writes: script py:if=True my_fun_method(); /script /body Though that somewhat defeats the purpose of onload. I want to run a JS function, not a Python function... This is part of the problem (the other part is that I don't know much

[TurboGears] Re: Using onload combined with py:if

2005-12-06 Thread Jorge Godoy
Bob Ippolito [EMAIL PROTECTED] writes: input type=hidden value=${message} id=show_message py:if=show_message / and the (probably external to the page) script would look something like: addLoadEvent(function () { var msg = getElement(show_message); if (!msg) return;

[TurboGears] Re: Using onload combined with py:if

2005-12-06 Thread Bob Ippolito
On Dec 6, 2005, at 1:19 PM, Jeff Watkins wrote: Bob Ippolito wrote: In these kinds of situations I prefer *never* to dynamically generate code. What I do instead is simply place a hidden input element in the page conditionally with whatever value is necessary, and the JavaScript code

[TurboGears] Re: Using onload combined with py:if

2005-12-06 Thread Michele Cella
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