Once again, thanks for all of this.  I will now go away and
contemplate it all.

On the face of it, as a newby, this JavaScript DSL adds another layer
of complexity to using Lift with JavaScript.  Is there an option to
use mostly raw JavaScript?  What are the advantages / disadvantages?

Sorry, I thought I'd get my moneys worth from you and then try to put
something onto the wiki.

Best,

Stuart.

On Mar 9, 5:35 pm, Ross Mellgren <[email protected]> wrote:
> That's why I factored this as a JQueryNodeSeq, so you can pass anything to 
> dialog (I've used JQuery, and figured you'd need to pass something in there 
> ;-)
>
> JQueryNodeSeq(ns) ~> JsFunc("dialog", JsObj("autoOpen" -> JsTrue, "width" -> 
> 500, ..., "close" -> AnonFunc(JsVal("this") ~> JsFunc("destroy"))))
>
> >>> case class JQueryNodeSeq(ns: NodeSeq) extends JsExp with JQueryLeft with 
> >>> HtmlFixer {
>
> JsExp is the basic trait of the JavaScript DSL. Anything that can go into a 
> JavaScript expression should have this trait.
> JQueryLeft is a trait used by the JQuery portion of the JavaScript DSL to 
> indicate that you can chain JQuery calls onto this.
> HtmlFixer is a trait that provides fixHtml
>
> >>>    override def toJsCmd = "jQuery(" + JsStr(fixHtml("NodeSeqDialog", 
> >>> ns)).toJsCmd + ")"
>
> fixHtml takes the given NodeSeq and does all the appropriate magics to 
> process lift: tags and then converts the NodeSeq to valid XHTML.
>
> >>> }
>
> And don't forget the security implications!
>
> Hope that helps,
> -Ross
>
> On Mar 9, 2010, at 12:30 PM, Stuart Roebuck wrote:
>
>
>
> > Thanks for that amazingly quick response!
>
> > I only wish I understood the proposed solution! :-)
>
> > So (confession time) I simplified things a little, the actual
> > JavaScript is…
>
> > var theDialog = $(…).dialog( { autoOpen: true, width: 500, modal:
> > true, close: function() { theDialog.destroy; }; } )
>
> > How do I assemble this, or is there any documentation / examples you
> > can point me to.
>
> > Thanks very much,
>
> > Stuart.
>
> > On Mar 9, 5:14 pm, Ross Mellgren <[email protected]> wrote:
> >> Whoops, I meant Str(fixHtml(...)) not JsStr(fixHtml(...))
>
> >> -Ross
>
> >> On Mar 9, 2010, at 12:14 PM, Ross Mellgren wrote:
>
> >>> Try this (I haven't tested it, so there could be lurking bugs):
>
> >>> case class JQueryNodeSeq(ns: NodeSeq) extends JsExp with JQueryLeft with 
> >>> HtmlFixer {
> >>>    override def toJsCmd = "jQuery(" + JsStr(fixHtml("NodeSeqDialog", 
> >>> ns)).toJsCmd + ")"
> >>> }
>
> >>> Then JQueryNodeSeq(ns) ~> JsFunc("dialog")
>
> >>> -Ross
>
> >>> On Mar 9, 2010, at 12:06 PM, Stuart Roebuck wrote:
>
> >>>> I'm trying to produce a web page with editable content.
>
> >>>> When the user clicks an edit button on a line it uses jQuery to
> >>>> display a modal dialog which allows fields of that line to be edited.
>
> >>>> I can easily produce a snippet to produce the lines using the backend
> >>>> data and an XHTML template and binding etc.
>
> >>>> However, I also want the template to include the template for the
> >>>> dialog.  So I want the ajax button callback to send JavaScript to
> >>>> instantiate the jQuery UI dialog based on the template and bindings.
>
> >>>> To build this I need to assemble a JsCmd containing the NodeSeq that
> >>>> comes from the XHTML sequence and the bindings.
>
> >>>> In short, if this was straight jQuery I would have some JavaScript of
> >>>> the form:
>
> >>>> $(<div title="Dialog Title">theFormNodeSeq</div>).dialog()
>
> >>>> But in my case theFormNodeSeq comes from a NodeSeq that was assembled
> >>>> from part of the XHTML template and the bindings and the end result
> >>>> needs to be a JsCmd.
>
> >>>> So I'm trying to do something like:
>
> >>>> JsCmds.Run("$(" + theFormNodeSeq.toString + ").dialog()")
>
> >>>> But I need to address escaping issues with the HTML and I also need to
> >>>> pre-process any "<lift:… />" commands in theFormNodeSeq.
>
> >>>> Any advice (please)?
>
> >>>> --
> >>>> You received this message because you are subscribed to the Google 
> >>>> Groups "Lift" group.
> >>>> To post to this group, send email to [email protected].
> >>>> To unsubscribe from this group, send email to 
> >>>> [email protected].
> >>>> For more options, visit this group 
> >>>> athttp://groups.google.com/group/liftweb?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Lift" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to 
> > [email protected].
> > For more options, visit this group 
> > athttp://groups.google.com/group/liftweb?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.

Reply via email to