[Lift] Re: how to use JqKeypress?
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 -~--~~~~--~~--~--~---
[Lift] Re: how to use JqKeypress?
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. } 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 -~--~~~~--~~--~--~---
[Lift] Re: how to use JqKeypress?
With the current function you can't. I can see a need for having the ajax fired on key press and not on blur, so please open an issue and reference this conversation. Derek On Tue, Oct 20, 2009 at 1:05 PM, harryh har...@gmail.com wrote: 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. } 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 -~--~~~~--~~--~--~---