Adding handlers to Nevow template tags (How do you keep the code separate from the presentation)


After a bit of annoyance with nevow:attr, I did figure out how one works with it, but in doing so, I found what seems to me to be a far more reasonable approach. Rather than having an extra nevow:attr tag, with a slot inside it that you fill from your render method, you can simply alter the tag in your render method directly using its attributes field:

ctx.tag.attributes['onchange'] = livepage.handler(
self.OnNewValue,
livepage.js('getValue')( globalID )
)

and then return ctx.tag as the result of the render method. Works perfectly well, and seems less cumbersome than the nevow:attr approach.

Comments

Comments are closed.

Pingbacks

Pingbacks are closed.