I've got some LiveElements in an Athena page to which I want to attach event handlers. Their XHTML is stan-based.
_js = ( "Nevow.Athena.Widget.get(this).keyPressed(this, event); " + "return false;" )
docFactory = loaders.stan ( T.div ( render = T.directive ( 'liveElement' ), ) [ "Blah Text Label", T.input ( type = "text", _class = "sw-input", onkeyup = _js, ), T.div ( _class = "sw-output" ) [ "Blah More Text" ], ] )
There are messages in the mailing list (for example, from JP on October 11th 2006) recommending that one should use the athena:handler feature, like this:
<textarea> <athena:handler event="onkeypress" handler="keyPressed" /> </textarea>
However, if one has stan-based rather than file-based XHTML, it's neither documented nor obvious how this should be done. I've managed to get this far:
from nevow import stan ... _athena = stan.Proto ( 'athena:handler event="onkeypress" handler="keyPressed"' ) ... T.input ( type = "text", _class = "sw-input" ) [ _athena ]
This serialises OK, but it doesn't work, because the node doesn't get rewritten; that is, the generated XHTML contains the athena:handler node verbatim.
What is the correct way to create such a node such that it gets picked up by rewriteEventHandlerNodes()?