You certainly can. The easiest way is with the JsonFunc:
val (jsonCall: JsonCall, jsCmd: JsCmd) = S.buildJsonFunc {
case JsonCmd("DoSomething", _, s, _) =>
println("Got "+s)
Alert("You entered: "+s)
case _ => Noop
}
In your page, include:
<span>
{
Script(jsCmd) // emit the JSON call
}
{
// emit the function "showElement" that has "x" as a param.
// when the function is called, invoke the JsonCall
Script(Function("showElement", List("x"), jsonCall("DoSomething",
JsVar("x"))))
}
</span>
See also
http://github.com/dpp/liftweb/tree/master/sites/example/src/main/scala/net/liftweb/example/snippet/Json.scala
On Tue, Nov 25, 2008 at 7:59 AM, Joachim A. <[EMAIL PROTECTED]>wrote:
>
> Hi,
> sorry for my posts. I have some difficult time with the Javascript
> stuff in Lift.
>
> I have some HTML which is generated by XSLT.
> This data contains links with javascript calls. I want that the
> javascript ends up as ajax calls to lift.
>
> Example data:
>
> <a onclick="showElement(1)">Show Element 1</a>
>
> Can I create a Javascript method "showElement" (with Lift's help or
> without it) which does an ajax request with Lift to show the specified
> Element?
>
> Thanks a lot,
> Joachim
>
> >
>
--
Lift, the simply functional web framework http://liftweb.net
Collaborative Task Management http://much4.us
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---