[Twisted-web] Re: nevow.liveevil question (dynamically adding a link with its own handler)

Thomas Hervé therve at free.fr
Wed Mar 2 15:11:15 MST 2005


On Dec 19, 2004, at 12:05 PM, David Moore wrote:

> def adder(client):
> #    newLink = loaders.stan(tags.a(href="#")["Nothing"])
>     newLink = loaders.stan(tags.a(href="#",
>                 onclick=liveevil.handler(adder))["AddAgain"])
>     client.append('content', newLink)

I got a similar problem and actually found the reason : you can't call
liveevil.handler in a function itself called by liveevil.handler (a function
aimed at javascript).

To make things work, I used a small hack :

### Code
def adder(client):
    newLink = tags.a(onclick="myfunc")["AddAgain"]
    client.append('content', newLink)
### END Code

In your page :

### Code
def render_myfunc(context, data);
    return liveevil.handler(adder)
### END Code

And in your html/stan/whatever :

### Code
<script language="javascript">
    function my_func() {
    <span nevow:render="myfunc" />
   }
</script>
### END Code

Hope it'll help

--
Thomas



More information about the Twisted-web mailing list