On Apr 16, 12:58 am, 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?
items is the same with your list variable. use JsVar("list")
>
> 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 don't get it. The Jx examples are described there ... It show
trivial Jx(<div>...<div>) and the JavaScript code generated, then it
goes with more complex examples. Do you have some concrete examples of
how would you want ti to be described. The lift book chapter have been
reviewed by multiple people and I don't recall anyone having troubles
with Jx.
>
> 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)
What java version are you using? SHtml.ajaxButton(Text(Press me),
ajaxFunc) should work as it should pass the function and not the
function evaluation. You can do partial function application:
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.
All examples in the LiftBook have been tested. Jx is a very powerful
artifact but for some reason people are staying away from it ... maybe
it's because it is not very simple to understand.
>
> 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
-~----------~----~----~----~------~----~------~--~---