On Fri, Jul 29, 2011 at 3:57 PM, Kenneth McDonald <ykke...@gmail.com> wrote:
> While reworking some older code, I came up with this as part of a snippet
> for rendering and processing a form:
> "#email *" #> FocusOnLoad(<input type="text" name="username"/>) &
> "name=username" #> SHtml.onSubmit(username = _) &
try this:
"name=username" #> SHtml.onSubmit(username = _) andThen
"#email *" #> FocusOnLoad(<input type="text" name="username"/>) &
if it works, I'll explain why :)
Well, I should just say it now, the andThen basically separates the
two replacements and makes sure that the first one is done before the
second one. if you separate them by a simple & , I *think* the order
is not guaranteed.
Hope it works
Diego
> So, I'm trying to ensure the username field has the cursor when the page is
> loaded. I'm also trying to make sure the local variable "username" is
> assigned the value of the username field when the form is submitted.
> Unfortunately, this doesn't work, no doubt because the <input type="text"
> name="username"/> is not actually part of the page being transformed
> when "name=username" #> SHtml.onSubmit(username = _) is executed. I've
> looked at FocusOnLoad and it needs an element--I can't get away with just
> giving it an id or something. So I suppose I need to put <input type="text"
> name="username"/> into the original form, get rid of FocusOnLoad, and figure
> out some other way to set the focus after the page loads. Any suggestions on
> the cleanest way to do this?
> Thanks,
> Ken
>
> --
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/liftweb/-/nkbD2pcNJcIJ.
> To post to this group, send email to lif...@googlegroups.com.
> To unsubscribe from this group, send email to
> liftweb+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=en.
>
--
Diego Medina
Web Developer
(305) 788-4954
di...@fmpwizard.com
http://www.fmpwizard.com
"name=username" #> SHtml.onSubmit(username = _) andThen
"#email *" #> FocusOnLoad(<input type="text" name="username"/>) &
Great!
Sent from my cell
Diego