I think that the ajaxText already handles an "enter" key as field
submission. Here's the code that defines an ajaxText field:


   1.   private def
    ajaxText_*(value: String, jsFunc: Box[Call], func: AFuncHolder,
attrs: (String, String)*): Elem = {
   2.     val raw = (funcName: String, value:String) => JsRaw("'"
    +funcName + "=' + encodeURIComponent(" + value + ".value)")
   3.     val key = formFuncName
   4.
   5.     fmapFunc(func){
   6.       funcName =>
   7.       (attrs.foldLeft(<input type="text" value={value}/>)(_ % _)) %
   8.       ("onkeypress" -> """liftUtils.lift_blurIfReturn(event)""") %
   9.       ("onblur" -> (jsFunc match {
   10.             case Full(f) => JsCrVar(key, JsRaw("this"
   )) & deferCall(raw(funcName, key), f)
   11.             case _ => makeAjaxCall(raw(funcName, "this"))
   12.           })
   13.       )
   14.     }
   15.   }


Note the "onkeypress" and "onblur" event handlers. If you need to do some
extra handling on the client side, you can provide the jsFunc parameter
which will be used to submit the ajax call.

Derek


On Mon, Oct 19, 2009 at 6:13 PM, harryh <har...@gmail.com> wrote:

>
> It seems like I ought to be able to use JqKeypress so that if a user
> presses enter when a text input has focus an associated ajaxButton is
> submitted.  I can't get it to work though.  Help?
>
> Basically I have a bunch of little form like so
>
> [      text input       ] [go!]
>
> that I want to submit (ajax style) when the user presses enter.
>
> -harryh
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to