Hi,
I ran into the same problem. The Alert case class takes only a string.
|case class Alert(val text : String
<http://java.sun.com/javase/6/docs/api/java/lang/String.html>)| |
|I.e. the result of getWidth is quoted such that it remains a plain
string when it is evaluated on client side. Best thing would be if Alert
was changed to accept a JsExp as parameter, then your code would work.
A (somewhat unpleasent) workaround would be:
|/* not checked for syntax */
def alert(what: JsExp) = {
JsRaw("alert(" + what.cmd + ");");
}
|
Maybe someone knows a more elegant way though.
Regards,
Eros
jhonig wrote:
> Hi All,
>
> I am trying to execute a local (ie: defined in the template)
> javascript function from an Ajax
> callback. This is the callback:
>
> def testAjax2 (theXhtml : NodeSeq) : NodeSeq =
> {
> def getWidth () =
> {
> Call ("getAvailableWidth").cmd;
> }
>
> def alert (what : String) =
> {
> Alert (what);
> }
>
> bind ("fgh", theXhtml, "key" -> SHtml.a (() => {alert
> (getWidth ());}, Text ("Click me")));
> }
>
> The alert is displayed, but the text it shows is "getAvailableWidth
> ()". I have been trying dozens
> of variations, but didn't get the result I am hoping for; it's always
> the string...
>
> What am I doing wrong?
>
> --
>
> 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=.
>
>
>
--
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=.