Hi Ross,

I haven't been able to test your solution yet, still struggling with
several other
issues.  I seldom feel this unproductive, I'm afraid, the lack of
documentation
and issues of what documentation are up to date are both troubling me.

Thanks for your help and I will definitely post back once I was
successful.

Job H.

PS: maybe I will now be someone else: google groups wanted me to re-
register to this group with a new nickname...

On Nov 18, 10:18 pm, Ross Mellgren <[email protected]> wrote:
> Yes, jsonCall is an extension of ajaxCall that automatically does the
> JSON conversion for you, which why you get an immutable.Map out of it
> rather than a blob of text. Let me know how it works out.
>
> -Ross
>
> On Nov 18, 2009, at 4:16 PM, jhonig wrote:
>
> > Hi Ross,
>
> > Thanks for your suggestion!  So I can actually use any jsonCall as if
> > it were
> > Ajax and deal with the result...  OK, nice.  Will try it out tomorrow!
>
> > Job
>
> > On Nov 18, 6:24 pm, Ross Mellgren <[email protected]> wrote:
> >> (n.b. not compiled or tested, and there might be an easier way:)
>
> >> class MySnippet {
> >>     def handlers(ns: NodeSeq): NodeSeq = {
> >>         val handleResize = SHtml.jsonCall(JE.JsObj("width" ->
> >> JE.JsVar
> >> ("window", "screen", "width"),
> >>                                                    "height" ->
> >> JE.JsVar("window", "screen", "height")),
> >>                                           obj => {
> >>             val result = for {
> >>                m <- (Box!!obj).asA[scala.collection.immutable.Map
> >> [String, Any]]
> >>                width  <- m.get("width").asA[Int]
> >>                height <- m.get("height").asA[Int]
> >>             } yield {
> >>                // do stuff with the width and height
>
> >>                // some JS command to send back to the browser
> >>                JsCmds.Noop
> >>             }
>
> >>             result.openOr(/* JS command to send back to browser if we
> >> failed to get arguments and so on */ JsCmds.Noop)
> >>         })._2
>
> >>         <head>{ Script {
> >>             Function("handleResize", Nil, handleResize)
> >>         } }</head>
> >>     }
>
> >> }
>
> >> Then in your template say onResize="handleResize()"
>
> >> Hope that gives you some pointers,
> >> -Ross
>
> >> On Nov 18, 2009, at 4:19 AM, jhonig wrote:
>
> >>> Hi All,
>
> >>> Yet another question: I need to make Ajax calls when a page is
> >>> loaded
> >>> or resized.  The call would need to pass some local client
> >>> information
> >>> (browser size).  The return should be javascript code that
> >>> populates a
> >>> div on that page (in particular: an image that is scaled on the
> >>> server
> >>> to match the browser size).   Actually, local js code is in place
> >>> that
> >>> makes the call only after the user has stopped resizing (using a
> >>> timeout).
>
> >>> I guess I have to use AjaxCall, providing an expression that puts
> >>> the
> >>> window dimensions in an array or list, then return the javascript to
> >>> add an <img> tag that downloads the scaled image from a generated
> >>> url.
>
> >>> Given the level of success I achieved so far, I thought I better ask
> >>> if this would work our before I start trying endlessly.
>
> >>> Thanks for any suggestions,
>
> >>> Job
>
> >>> --
>
> >>> 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=
> >>> .
>
> > --
>
> > 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=.


Reply via email to