Again LiftBook examples are working example ... I can double check today though.
Could you send me a minimalistic example (and not just snippet) that does not work? Br's, Marius On Apr 16, 1:19 am, 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. > > 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 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---