On Mon, Aug 24, 2009 at 2:16 AM, pravin <[email protected]> wrote:
>
> Hi
> i have form with text box and Submit button(with ajax Submit button)
>
> But when i submit the button form is not submitting so i am not able
> to get the value of text box..
> onclick function get called...
SHtml.ajaxButton is just that... a <button> that, when clicked by the user,
performs an ajax call to the server.
>
>
> Just i want to show text value in response with ajax ...
> how can i do this
Use SHtml.ajaxForm:
class Form2 {
def render(xhtml: NodeSeq): NodeSeq = {
var user = ""
def doAjaxThing(): JsCmd = {
SetHtml("updated",
<span>Hey Dude... I'm Form2 and the user is {user}</span>)
}
SHtml.ajaxForm(
bind("form", xhtml,
"user" -> SHtml.text(user, user = _),
"submit" -> (SHtml.hidden(doAjaxThing _) ++
<input type="submit" value="Click Me"/>)
))
}
}
Or, if you use the <lift:form> tag in your view:
<div>
Ajax Form v1: <br/>
<lift:form>
<lift:Form1>
User: <form:user/> <br/>
Okay? <form:submit/>
</lift:Form1>
</lift:form>
</div>
You can do:
class Form1 {
def render(xhtml: NodeSeq): NodeSeq = {
var user = ""
def doAjaxThing(): JsCmd = {
SetHtml("updated",
<span>Hey Dude... I'm Form1 and the user is {user}</span>)
}
bind("form", xhtml,
"user" -> SHtml.text(user, user = _),
"submit" -> (SHtml.hidden(doAjaxThing _) ++
<input type="submit" value="Click Me"/>)
)
}
}
In enclosing running code that demonstrates both.
Thanks,
David
>
>
> >
>
--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
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
-~----------~----~----~----~------~----~------~--~---
ajaxform.tgz
Description: GNU Zip compressed data
