On Tue, Dec 29, 2009 at 12:59 PM, greekscala <[email protected]> wrote:
> class Test {
> object name extends RequestVar[String]("init")
>
> def render(xml: NodeSeq): NodeSeq = {
> def printName(): JsCmd = {
> Log.debug("name = " + name.is)
>
> JsCmds.Alert("an ajax response! "+ name.is)
> }
> SHtml.ajaxForm(
> Helpers.bind("atest", xml,
> "name" -> SHtml.text(name.is, name(_)),
> "submit" -> SHtml.submit("add", printName)
> ), JsCmds._Noop, printName
> )
>
> /*
> SHtml.ajaxForm(
> Helpers.bind("atest", xml,
> "name" -> SHtml.text(name.is, name(_)),
> "submit" -> SHtml.submit("add", printName)
> ) ++ SHtml.hidden(printName)
> )
> */
> }
> }
>
> This is the template:
> <lift:surround with="default" at="col3">
> <lift:Test>
> <atest:name />
> <atest:submit />
> </lift:Test>
> </lift:surround>
>
> The problem is with the uncommented ajaxForm code, when the form is
> submitted the name RequestVar is not updated. I seems that the
> function
> bound to the name-Textfield is not invoked. So I get back "an ajax
> response! init".
>
It's invoked but it's invoked before the form field callbacks have been
called so the field still holds the initial value. (I've been wondering if
this is the right behavior myself.)
The SHtml.hidden() callback is called after the form field callbacks so
that's probably the one you want to use for now.
alex
--
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.