Marius, You asked about the Java version I'm using and why I couldn't run the Liftbook example as-is.
My development environment is Eclipse with the scala plugin running Java 1.6. I assume I'm always compiling with the latest scala/lift libraries, as I use maven to package and run. I get the following compiler error: "overloaded method value ajaxButton with alternatives (String,() => net.liftweb.http.js.JsCmd,(String, String)*)scala.xml.Elem <and> (scala.xml.NodeSeq,() => net.liftweb.http.js.JsCmd,(String, String)*) scala.xml.Elem cannot be applied to (scala.xml.Text,net.liftweb.http.js.JsCmd) TabMenu.scala sample/src/ main/scala/com/exmbly/scala/sample/snippet Unknown Scala Problem" Changing the call to bind("ex", xhtml, "button" -> SHtml.ajaxButton(Text(Press me), () => ajaxFunc) does work, however (Press me needs to be quoted. It's not in the book). Glenn Silverman On Apr 16, 6:49 am, David Pollak <feeder.of.the.be...@gmail.com> wrote: > On Wed, Apr 15, 2009 at 3:19 PM, glenn <gl...@exmbly.com> wrote: > > > Actually, the json example code in the Liftbook works, as long > > as you change it to read: > > > bind("ex", xhtml, > > "button" -> SHtml.ajaxButton(Text(Press me), () => ajaxFunc) > > > But this example uses a simple function, alert, and emits it using > > JsRaw. > > > I would like to see a similar example, but using Jx to emit a > > javascript function and have it called. > > Jx is for generating functions that generate XML on the client side. It's > for building rich client-side applications. > > In the button example, the code being called is on the server side, so the > client-side code is less relevant. > > If you could talk about what you're trying to build, it might be easier to > discuss things in concrete terms rather than in abstract terms. > > Thanks, > > David > > > > > > > Glenn Silverman > > > On Apr 15, 2:58 pm, glenn <gl...@exmbly.com> wrote: > > > Marius, > > > > I appreciate the reply. Not sure if it helps, though. What's with > > > (JsVar("items") and why did you use that? > > > > The Liftbook is very cryptic on the use of Jx classes. It just says, > > > > " If we send this generated JavaScript function to client and calling > > > it by pass the list variable > > > above It will create the following document fragment:..." > > > > Nothing in the book about how to actually do this. > > > > I tried the json example in the book (sec 8.4) and all I got emitted > > > on the client was: > > > <button onclick="lift_ajaxHandler('F560600551708Y4K=true', null, > > > null); return false;">Press me</button> > > > > That doesn't do any good. Generated variable names in emitted > > > javascript aren't much good for referencing in scala classes. > > > > The book is wrong by the way. This won't compile. > > > > bind("ex", xhtml, > > > "button" -> SHtml.ajaxButton(Text(Press me), ajaxFunc) > > > > You need to do something like this: > > > > bind("ex", xhtml, > > > "button" -> SHtml.ajaxButton(Text(Press me), () => ajaxFunc) > > > > Maybe that's why I'm getting 'F560600551708Y4K=true' emitted. > > > > I'm beginning to think nobody has actually written code using the Jx > > > classes > > > that works. > > > > Glenn Silverman > > > > On Apr 15, 12:30 pm, "marius d." <marius.dan...@gmail.com> wrote: > > > > > How about > > > > > 1. Use a decalred variable > > > > > JsCrVar("func", Jx(<ul>{ > > > > JxMap(JsVar("it"), Jx(<li><a > > > > href="">{JsVar("it")}</a></li>)) > > > > } > > > > </ul>).toJs) & Call("func", JsVar > > > > ("items")) > > > > > 2. > > > > > Jx(<ul>{ > > > > JxMap(JsVar("it"), Jx(<li><a href="">{JsVar("it")}</a></li>)) > > > > }</ul>).toJs asInstanceOf[AnonFunc].applied(JsVar("items")) > > > > > ... that should just call the anonymous function constructed by Jx > > > > > Note that I haven't actaully tested the code but is should work unless > > > > I'm missing some parentheses etc. > > > > > Also Jx is discussed in the LiftBook > > > > > Br's, > > > > Marius > > > > > On Apr 15, 9:25 pm, glenn <gl...@exmbly.com> wrote: > > > > > > I'm a novice at this, and I've seen discussions of using Jx classes > > to > > > > > output HTML on the client, but how exactly is this done? Are there > > > > > any complete examples of sending JavaScript functions produced by the > > > > > Jx classes to the client and running them? > > > > > > Suppose, for example, I have a json object: > > > > > > var list = { > > > > > tabs: [ > > > > > {class: posts selected}, > > > > > {class: comments}, > > > > > {class: category}, > > > > > {class: famous}, > > > > > {class: random} > > > > > ] > > > > > } > > > > > > and a function defined so: > > > > > > def renderTabs = Jx(<li class='{JsVar("it", "class")}'></li>) > > > > > > I then want to create tabs on the client with > > > > > > Jx(<ul class="tabMenu">{JxMap(JsVar("it.tabs"), renderTabs)}</ul>) > > > > > > How, exactly is this to be done? Obviously, this won't work - the > > > > > JavaScript function isn't generated: > > > > > > def head(xhtml:NodeSeq): NodeSeq = { > > > > > > val renderTabs = Jx(<li class='{JsVar("it", "class")}'></li>) > > > > > > <head> > > > > > <script type="text/javascript"> > > > > > Jx(<ul class="tabMenu">{JxMap(JsVar("it.tabs"), > > > > > renderTabs)}</ul>) > > > > > > </script> > > > > > </head> > > > > > } > > > > > > I see the value in the Jx classes, if only I knew how to use them. > > > > > Any help would be appreciated > > > > > > Glenn Silverman > > -- > Lift, the simply functional web frameworkhttp://liftweb.net > Beginning Scalahttp://www.apress.com/book/view/1430219890 > Follow me:http://twitter.com/dpp > Git some:http://github.com/dpp --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---