Yes, but then how can I distinguish back on the server whether func is
being executed because of a blur (in which case I don't really want to
do anything) or because of a keypress of enter (in which case I want
to perform an action as if the go button had been pressed).
-harryh
On Oct 20, 11:27 am, Derek Chen-Becker <
dchenbec...@gmail.com> wrote:
> 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. }