Maybe write javascript code that gets all its variables by calling functions. 
Then supply those functions as Lift JsXX. This way you can supply values from 
Lift but the javascript "program" is written in javascript.


-------------------------------------
glenn<gl...@exmbly.com> wrote:


Ross,

I think you and I  came to same conclusion. Writing it as raw
JavaScript, as I
did initially, seems the only way I could find to do this. FYI, where
I was using this
was with the TreeView widget. There, "toggle" takes an anonymous
function, and
"this" is an implicit parameter, denoting the Tree selected.

val func = JsRaw("""function() $('#item-save').html(this.id + ' was
toggled')""")
TreeView("tree", JsObj(("persist", "location"),("toggle",  func)),
loadTree, loadNode)


I was hoping for a more functional way to write func, in order to do
more complex processing on the client.

Glenn



On Sep 29, 2:55 pm, Ross Mellgren <dri...@gmail.com> wrote:
> Oh I'm sorry, I got tunnel vision and did not read the rest of your  
> code. You'll not be able to do quite what you want, since this.id is  
> on the javascript side and the NodeSeq is on the server side.
>
> If you really want this.id within that div, I think you'll have to  
> construct or modify the div on the JS side. I rummaged through the  
> Lift jQuery docs and I couldn't find something that will append/inject  
> to a JQueryLeft (such as JqId) but using a JsExp and not a fixed  
> NodeSeq. This is not to say there isn't such a thing, just that I  
> couldn't find it. Of course, you can whip this up using the lower  
> level javascript stuff:
>
> AnonFunc(JqId("item-save") ~>
>           JsFunc("empty") ~>
>           JsFunc("after", Call("jQuery", "<div> was toggled</div>") ~>
>                           JsFunc("prepend", JsVar("this", "id"))))
>
> Of course, at that point I'd just say it might be a better idea to  
> write the JavaScript directly, since this expands to
>
> $("#item-save").empty().after($("<div> was toggled</div>").prepend
> (this.id));
>
> -Ross
>
> On Sep 29, 2009, at 5:22 PM, glenn wrote:
>
>
>
> > Hi, Ross,
>
> > Unfornately, all of these just result in:
>
> > function() {jQuery('#'+"item-save").empty().after("<div>this.id was
> > toggled</div>");}
>
> > They simply treat this.id as part of the passed in NodeSeq,
> > "<div>this.id was toggled</div>". I need it
> > to output <div>this.id + "was toggled"</div>.
>
> > Glenn
>
> > On Sep 29, 1:46 pm, Ross Mellgren <dri...@gmail.com> wrote:
> >> Try JsVar("this", "id") or JsRaw("this.id")
>
> >> -Ross
>
> >> On Sep 29, 2009, at 4:22 PM, glenn 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>))
>
> >>> but nothing seems to work. It just treats this.id as ordinary text,
> >>> not as a Javascript variable.
>
> >>> Any ideas would be appreciated.
>
> >>> Glenn


--~--~---------~--~----~------------~-------~--~----~
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