Skip to content

Instantly share code, notes, and snippets.

@tjweir
Created May 2, 2009 00:26
Show Gist options
  • Select an option

  • Save tjweir/105338 to your computer and use it in GitHub Desktop.

Select an option

Save tjweir/105338 to your computer and use it in GitHub Desktop.
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