I often find it convenient to trace what's happening with snippets by
inspecting the html produced in Firebug.

Currently, I'm using a short snippet that logs event output to the
Firebug console. It doesn't cover all the bases but it's quick and
dirty. Anyone doing something similar???

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>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to