Created
May 2, 2009 00:26
-
-
Save tjweir/105338 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Trace { | |
| def head(script:JsCmd) = <head>{Script(script)}</head> | |
| def render(xhtml: NodeSeq): NodeSeq = { | |
| val id = S.attr("id").openOr("") | |
| val event = S.attr("event").openOr("keyup") | |
| val msg = S.attr("msg").openOr("You typed") | |
| def logit = new JsExp with JQueryRight { | |
| def toJsCmd = "console.log('" + event + "(" + event + ") %s: | |
| %s','" + msg + "', this.value)" | |
| } | |
| def jsCmd = new JsExp with JQueryRight { | |
| def toJsCmd = event + "(" + AnonFunc(logit).toJsCmd + ")" | |
| } | |
| head(OnLoad(JqId(id) >> jsCmd)) | |
| } | |
| } | |
| And a simple use-case: | |
| <lift:surround with="default" at="content"> | |
| <h2>Welcome to your project!</h2> | |
| <p><lift:helloWorld.howdy /></p> | |
| <lift:Trace id="comments" event="keyup" /> | |
| <textarea id="comments"/> | |
| </lift:surround> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment