A previous thread suggested overriding finishButton to be <button
type="submit">..., but that doesn't seem to work, probably because the
Cancel and Finish buttons are in a different form than the fields.
I'd generally like this to be the default behavior for all my forms,
so I'd like an easy way to set it once and then use it easily.
Todd
I don't know if it qualifies as the best way, but we ended up using
jQuery for this. Specifically,
http://plugins.jquery.com/project/SafeEnter along with something like
$('input[type="text"]', $('#myForm')).clickOnEnter($('#myFinishBtn'))
Pete
> --
> You received this message because you are subscribed to the Google Groups "Lift" group.
> 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.
>
>
What's the best way to have a LiftScreen form submitted when the user
presses the enter key in a field?
A previous thread suggested overriding finishButton to be <button
type="submit">..., but that doesn't seem to work, probably because the
Cancel and Finish buttons are in a different form than the fields.
I'd generally like this to be the default behavior for all my forms,
so I'd like an easy way to set it once and then use it easily.
Todd
--
You received this message because you are subscribed to the Google Groups "Lift" group.
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.
IIRC, in my experience, enter worked only on the last form on the
page, but nowhere else. My assumption was that it was just browser
weirdness vs. anything specific Lift is doing.
Pete
Thanks for picking this up so quickly David!
We're currently using jQuery to work around this fairly painlessly.
Let me know if you want details on that.
Pete
> To view this discussion on the web visit
> https://groups.google.com/d/msg/liftweb/-/vmbJ7whvWqwJ.
We're currently using jQuery to work around this fairly painlessly.
Let me know if you want details on that.
http://groups.google.com/group/liftweb/browse_thread/thread/74412a2fca848787/6e8df081348e55a1
(which is actually this thread!)
Pete
On Fri, Aug 26, 2011 at 4:14 PM, Sergey Trofimov
The short answer is implementation convenience. It will be fixed, but
I'm sorry I don't have an ETA.
Pete
On Thu, Oct 20, 2011 at 11:22 AM, Sergey Trofimov
> Code: http://github.com/lift
> Discussion: http://groups.google.com/group/liftweb
> Stuck? Help us help you:
> https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>
Can you expand on how you do this with jQuery? Specifically, how do
you figure out the names/ids of the forms and buttons in your
LiftScreen so that you can access them with the JavaScript? The
totality of my HTML and snippet for my login page are:
<div class="lift:UserLogin"></div>
object UserLogin extends LiftScreen {
object user extends ScreenVar[Box[User]](Empty)
val username = field("Username", "")
val passwd = password("Password", "")
def authenticateUser(): List[FieldError] = {
user(User.authenticate(username.get, passwd.get))
if (user.get.isDefined) Nil else Text("Incorrect username or password.")
}
override def validations = authenticateUser _ +: super.validations
def finish() {
// user must be Full if we get here
User.login(user.get.open_!)
}
}
so I'm not at all sure where I'd put the JavaScript code you listed
and how I'd get it to know about the submit button or the form.
Thanks!
Todd
P.S. Sorry to drudge up an old subject, but other things are starting
to work, so this issue has climbed up on the annoyance list.