David,

Excellent. This is exactly what I was looking for.

Thanks.

Glenn

On Sep 30, 4:54 pm, David Pollak <feeder.of.the.be...@gmail.com>
wrote:
> JqHtml and JqEmptyAfter eagerly evaluate the NodeSeq on the server, so
> there's no way to get client-side JS execution in a NodeSeq.
> You can write something like:
>
> object MyJqText {
>     def apply(content: JsExp) = new JsExp with JQueryRight with JQueryLeft {
>       def toJsCmd = "text("+content.toJsCmd+")"
>     }
>   }
>
> So:
>
> JqId("item-save") >> MyJqText(JsVar("this", "id") + " has changed")
>
>
>
> On Wed, Sep 30, 2009 at 2:05 PM, glenn <gl...@exmbly.com> wrote:
>
> > As I mentioned, I was looking for a way to translate this JavaScript
>
> > $('#item-save').html(this.id + ' was toggled')
>
> > into a JsCmd so I could coded it my snipped as AnonFunc(some jsCmd).
>
> > I know I can just use JsRaw, but who in their right mind wants to
> > write JavaScript
> > if it can be avoided.
>
> > Glenn
>
> > On Sep 30, 1:20 pm, David Pollak <feeder.of.the.be...@gmail.com>
> > wrote:
> > > On Wed, Sep 30, 2009 at 1:08 PM, glenn <gl...@exmbly.com> wrote:
>
> > > > David,
>
> > > > The problem with writting the NodeSeq as <div>{this.id} was toggled</
> > > > div>)
> > > > is that it generates the following JavaScript:
>
> > > > function() {jQuery('#'+"item-save").empty().after("<div>-1 was
> > > > toggled</div>");
>
> > > > that is, Lift evaluates {this.id} in relation to the snippet, then
> > > > outputs the value
> > > > in the JavaScript - not the result I'm after.
>
> > > What are you after?  What is "this" in the context?
>
> > > > Glenn...
>
> > > > On Sep 30, 11:41 am, David Pollak <feeder.of.the.be...@gmail.com>
> > > > wrote:
> > > > > On Wed, Sep 30, 2009 at 11:36 AM, glenn <gl...@exmbly.com> wrote:
>
> > > > > > David,
>
> > > > > > I can't do this, AnonFunc(JqId("item-save") >> JqEmptyAfter
> > > > > > (<div>this.id was
> > > > > > > toggled</div>)) , if that's what you mean.
>
> > > > > That's not what I wrote.  Please look again at the curly braces
> > around
> > > > the
> > > > > this.id:
>
> > > > > AnonFunc(JqId("item-save") >> JqEmptyAfter(<div>{this.id}
> > > > > was toggled</div>))
>
> > > > > > This generates the following JavaScript:
>
> > > > > > function() {jQuery('#'+"item-save").empty().after("<div>this.idwas
> > > > > > toggled</div>");
>
> > > > > > and that won't do. What's needed is something more akin to:
>
> > > > > > function() {jQuery('#'+"item-save").empty().after("<div>" +
> > this.id +
> > > > > > "was toggled</div>");
>
> > > > > > So, I guess my question is how do I define a NodeSeq to accomplish
> > > > > > this?
>
> > > > > > Glenn
>
> > > > > > On Sep 30, 10:40 am, David Pollak <feeder.of.the.be...@gmail.com>
> > > > > > wrote:
> > > > > > > On Tue, Sep 29, 2009 at 1:22 PM, glenn <gl...@exmbly.com> wrote:
>
> > > > > > > > I'd like to converting the following
>
> > > > > > > > JsRaw("""function() $('#item-save').html(this.id + ' was
> > > > > > > > toggled')""")
>
> > > > > > > > into something more object-oriented, using JQuery support
> > functions
> > > > in
> > > > > > > > Lift.
>
> > > > > > > > I've tried various combiniations, including this
>
> > > > > > > > AnonFunc(JqId("item-save") >> JqEmptyAfter(<div>{JsRaw(this.id
> > )}
> > > > was
> > > > > > > > toggled</div>))
>
> > > > > > > AnonFunc(JqId("item-save") >> JqEmptyAfter(<div>{this.id} was
> > > > > > > toggled</div>))
>
> > > > > > > No reason to promote this.id into some JavaScript thing.  It's
> > part
> > > > of
> > > > > > the
> > > > > > > XML literal.  The XML literal is generated server-side as part of
> > the
> > > > > > > JavaScript function.
>
> > > > > > > > but nothing seems to work. It just treats this.id as ordinary
> > > > text,
> > > > > > > > not as a Javascript variable.
>
> > > > > > > > Any ideas would be appreciated.
>
> > > > > > > > Glenn
>
> > > > > > > --
> > > > > > > Lift, the simply functional web frameworkhttp://liftweb.net
> > > > > > > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > > > > > > Follow me:http://twitter.com/dpp
> > > > > > > Surf the harmonics
>
> > > > > --
> > > > > Lift, the simply functional web frameworkhttp://liftweb.net
> > > > > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > > > > Follow me:http://twitter.com/dpp
> > > > > Surf the harmonics
>
> > > --
> > > Lift, the simply functional web frameworkhttp://liftweb.net
> > > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > > Follow me:http://twitter.com/dpp
> > > Surf the harmonics
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Surf the harmonics
--~--~---------~--~----~------------~-------~--~----~
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