[Lift] Re: A gap in my knowledge, JsCommands
On Wed, Apr 1, 2009 at 2:55 PM, Derek Chen-Becker dchenbec...@gmail.comwrote: It looks like it's missing a function call. Compare onclick=lift_ajaxHandler(... to onclick=(F687305521435R3K,lift_ajaxHandler I'm no JS guru, so that second one might be perfectly valid JS, but it looks weird to me. I'd recommend to stay away from referring to objects by reference instead of by id.. (all kinds of weird stuff can happen when you start to remove objects/have partial rendering) I.e. somefun('F687305521435R3K',lift_ajaxHandler) instead of somefun(F687305521435R3K,lift_ajaxHandler) (Note the single-quotes.) Derek On Tue, Mar 31, 2009 at 9:57 AM, TylerWeir tyler.w...@gmail.com wrote: I'm wading into an area that I'm a bit unfamiliar with and not sure if I'm running in a bug. Snippet code: class HelloWorld { def ajaxFunc1() : JsCmd = JsRaw(alert('Button1 clicked')) def ajaxFunc2(str: String) : JsCmd = { Log.info(Received + str) JsRaw(alert('Button2 clicked')) } def renderAjaxButtons(xhtml: NodeSeq): NodeSeq = { bind(ex, xhtml, button1 - SHtml.ajaxButton(Press Me, ajaxFunc1 _), button2 - buttonPress Me 2/button % (onclick - SHtml.ajaxCall(Str(Button-2), ajaxFunc2 _))) } } Which is in this template: lift:HelloWorld.renderAjaxButtons ex:button1 /br / ex:button2 /br / /lift:HelloWorld.renderAjaxButtons And is rendered thusly: button onclick=lift_ajaxHandler('F687305521434PIG=true', null, null); return false;Press Me/buttonbr / button onclick=(F687305521435R3K,lift_ajaxHandler ('F687305521435R3K=' + 'Button-2', null, null))Press Me 2/ buttonbr / Button 1 is find, but Button 2 causes FireBug to whine: F687305521435R3K is not defined onclick(click clientX=500, clientY=239)2 (line 2) [Break on this error] F687305521435R3K, lift_ajaxHandl...F687305521435R3K=Button-2, null, null); Does the second onclick look incorrect to you? -- Viktor Klang Senior Systems Analyst --~--~-~--~~~---~--~~ 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: A gap in my knowledge, JsCommands
Excellent, thanks Derek, Vik, I'm back on this today. On Apr 1, 9:03 am, Viktor Klang viktor.kl...@gmail.com wrote: On Wed, Apr 1, 2009 at 2:55 PM, Derek Chen-Becker dchenbec...@gmail.comwrote: It looks like it's missing a function call. Compare onclick=lift_ajaxHandler(... to onclick=(F687305521435R3K,lift_ajaxHandler I'm no JS guru, so that second one might be perfectly valid JS, but it looks weird to me. I'd recommend to stay away from referring to objects by reference instead of by id.. (all kinds of weird stuff can happen when you start to remove objects/have partial rendering) I.e. somefun('F687305521435R3K',lift_ajaxHandler) instead of somefun(F687305521435R3K,lift_ajaxHandler) (Note the single-quotes.) Derek On Tue, Mar 31, 2009 at 9:57 AM, TylerWeir tyler.w...@gmail.com wrote: I'm wading into an area that I'm a bit unfamiliar with and not sure if I'm running in a bug. Snippet code: class HelloWorld { def ajaxFunc1() : JsCmd = JsRaw(alert('Button1 clicked')) def ajaxFunc2(str: String) : JsCmd = { Log.info(Received + str) JsRaw(alert('Button2 clicked')) } def renderAjaxButtons(xhtml: NodeSeq): NodeSeq = { bind(ex, xhtml, button1 - SHtml.ajaxButton(Press Me, ajaxFunc1 _), button2 - buttonPress Me 2/button % (onclick - SHtml.ajaxCall(Str(Button-2), ajaxFunc2 _))) } } Which is in this template: lift:HelloWorld.renderAjaxButtons ex:button1 /br / ex:button2 /br / /lift:HelloWorld.renderAjaxButtons And is rendered thusly: button onclick=lift_ajaxHandler('F687305521434PIG=true', null, null); return false;Press Me/buttonbr / button onclick=(F687305521435R3K,lift_ajaxHandler ('F687305521435R3K=' + 'Button-2', null, null))Press Me 2/ buttonbr / Button 1 is find, but Button 2 causes FireBug to whine: F687305521435R3K is not defined onclick(click clientX=500, clientY=239)2 (line 2) [Break on this error] F687305521435R3K, lift_ajaxHandl...F687305521435R3K=Button-2, null, null); Does the second onclick look incorrect to you? -- Viktor Klang Senior Systems Analyst --~--~-~--~~~---~--~~ 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: A gap in my knowledge, JsCommands
Rewriting ajaxCall_* to incorporate Vik's idea fixes this: private def ajaxCall_*(jsCalcValue: JsExp, func: AFuncHolder): (String, JsExp) = { val (n, r) = fmapFunc(func)(name = (name, makeAjaxCall(JsRaw('+name+=' + +jsCalcValue.toJsCmd (' + n + ', r) } Thanks. On Apr 1, 9:37 am, TylerWeir tyler.w...@gmail.com wrote: Excellent, thanks Derek, Vik, I'm back on this today. On Apr 1, 9:03 am, Viktor Klang viktor.kl...@gmail.com wrote: On Wed, Apr 1, 2009 at 2:55 PM, Derek Chen-Becker dchenbec...@gmail.comwrote: It looks like it's missing a function call. Compare onclick=lift_ajaxHandler(... to onclick=(F687305521435R3K,lift_ajaxHandler I'm no JS guru, so that second one might be perfectly valid JS, but it looks weird to me. I'd recommend to stay away from referring to objects by reference instead of by id.. (all kinds of weird stuff can happen when you start to remove objects/have partial rendering) I.e. somefun('F687305521435R3K',lift_ajaxHandler) instead of somefun(F687305521435R3K,lift_ajaxHandler) (Note the single-quotes.) Derek On Tue, Mar 31, 2009 at 9:57 AM, TylerWeir tyler.w...@gmail.com wrote: I'm wading into an area that I'm a bit unfamiliar with and not sure if I'm running in a bug. Snippet code: class HelloWorld { def ajaxFunc1() : JsCmd = JsRaw(alert('Button1 clicked')) def ajaxFunc2(str: String) : JsCmd = { Log.info(Received + str) JsRaw(alert('Button2 clicked')) } def renderAjaxButtons(xhtml: NodeSeq): NodeSeq = { bind(ex, xhtml, button1 - SHtml.ajaxButton(Press Me, ajaxFunc1 _), button2 - buttonPress Me 2/button % (onclick - SHtml.ajaxCall(Str(Button-2), ajaxFunc2 _))) } } Which is in this template: lift:HelloWorld.renderAjaxButtons ex:button1 /br / ex:button2 /br / /lift:HelloWorld.renderAjaxButtons And is rendered thusly: button onclick=lift_ajaxHandler('F687305521434PIG=true', null, null); return false;Press Me/buttonbr / button onclick=(F687305521435R3K,lift_ajaxHandler ('F687305521435R3K=' + 'Button-2', null, null))Press Me 2/ buttonbr / Button 1 is find, but Button 2 causes FireBug to whine: F687305521435R3K is not defined onclick(click clientX=500, clientY=239)2 (line 2) [Break on this error] F687305521435R3K, lift_ajaxHandl...F687305521435R3K=Button-2, null, null); Does the second onclick look incorrect to you? -- Viktor Klang Senior Systems Analyst --~--~-~--~~~---~--~~ 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: A gap in my knowledge, JsCommands
I pushed code to SHtml.scala to fix ajaxCall and ajaxInvoke. It's here: http://github.com/dpp/liftweb/tree/tjweir-shtml-js-fix On Apr 1, 10:59 am, TylerWeir tyler.w...@gmail.com wrote: Rewriting ajaxCall_* to incorporate Vik's idea fixes this: private def ajaxCall_*(jsCalcValue: JsExp, func: AFuncHolder): (String, JsExp) = { val (n, r) = fmapFunc(func)(name = (name, makeAjaxCall(JsRaw('+name+=' + +jsCalcValue.toJsCmd (' + n + ', r) } Thanks. On Apr 1, 9:37 am, TylerWeir tyler.w...@gmail.com wrote: Excellent, thanks Derek, Vik, I'm back on this today. On Apr 1, 9:03 am, Viktor Klang viktor.kl...@gmail.com wrote: On Wed, Apr 1, 2009 at 2:55 PM, Derek Chen-Becker dchenbec...@gmail.comwrote: It looks like it's missing a function call. Compare onclick=lift_ajaxHandler(... to onclick=(F687305521435R3K,lift_ajaxHandler I'm no JS guru, so that second one might be perfectly valid JS, but it looks weird to me. I'd recommend to stay away from referring to objects by reference instead of by id.. (all kinds of weird stuff can happen when you start to remove objects/have partial rendering) I.e. somefun('F687305521435R3K',lift_ajaxHandler) instead of somefun(F687305521435R3K,lift_ajaxHandler) (Note the single-quotes.) Derek On Tue, Mar 31, 2009 at 9:57 AM, TylerWeir tyler.w...@gmail.com wrote: I'm wading into an area that I'm a bit unfamiliar with and not sure if I'm running in a bug. Snippet code: class HelloWorld { def ajaxFunc1() : JsCmd = JsRaw(alert('Button1 clicked')) def ajaxFunc2(str: String) : JsCmd = { Log.info(Received + str) JsRaw(alert('Button2 clicked')) } def renderAjaxButtons(xhtml: NodeSeq): NodeSeq = { bind(ex, xhtml, button1 - SHtml.ajaxButton(Press Me, ajaxFunc1 _), button2 - buttonPress Me 2/button % (onclick - SHtml.ajaxCall(Str(Button-2), ajaxFunc2 _))) } } Which is in this template: lift:HelloWorld.renderAjaxButtons ex:button1 /br / ex:button2 /br / /lift:HelloWorld.renderAjaxButtons And is rendered thusly: button onclick=lift_ajaxHandler('F687305521434PIG=true', null, null); return false;Press Me/buttonbr / button onclick=(F687305521435R3K,lift_ajaxHandler ('F687305521435R3K=' + 'Button-2', null, null))Press Me 2/ buttonbr / Button 1 is find, but Button 2 causes FireBug to whine: F687305521435R3K is not defined onclick(click clientX=500, clientY=239)2 (line 2) [Break on this error] F687305521435R3K, lift_ajaxHandl...F687305521435R3K=Button-2, null, null); Does the second onclick look incorrect to you? -- Viktor Klang Senior Systems Analyst --~--~-~--~~~---~--~~ 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: A gap in my knowledge, JsCommands
On Apr 1, 5:59 pm, TylerWeir tyler.w...@gmail.com wrote: Rewriting ajaxCall_* to incorporate Vik's idea fixes this: private def ajaxCall_*(jsCalcValue: JsExp, func: AFuncHolder): (String, JsExp) = { val (n, r) = fmapFunc(func)(name = (name, makeAjaxCall(JsRaw('+name+=' + +jsCalcValue.toJsCmd (' + n + ', r) Tyler instead of ' + n + ' we usually use encJs so the return tuple would become (n.encJs, r). If you are ok with this can you please update it in github ? } Thanks. On Apr 1, 9:37 am, TylerWeir tyler.w...@gmail.com wrote: Excellent, thanks Derek, Vik, I'm back on this today. On Apr 1, 9:03 am, Viktor Klang viktor.kl...@gmail.com wrote: On Wed, Apr 1, 2009 at 2:55 PM, Derek Chen-Becker dchenbec...@gmail.comwrote: It looks like it's missing a function call. Compare onclick=lift_ajaxHandler(... to onclick=(F687305521435R3K,lift_ajaxHandler I'm no JS guru, so that second one might be perfectly valid JS, but it looks weird to me. I'd recommend to stay away from referring to objects by reference instead of by id.. (all kinds of weird stuff can happen when you start to remove objects/have partial rendering) I.e. somefun('F687305521435R3K',lift_ajaxHandler) instead of somefun(F687305521435R3K,lift_ajaxHandler) (Note the single-quotes.) Derek On Tue, Mar 31, 2009 at 9:57 AM, TylerWeir tyler.w...@gmail.com wrote: I'm wading into an area that I'm a bit unfamiliar with and not sure if I'm running in a bug. Snippet code: class HelloWorld { def ajaxFunc1() : JsCmd = JsRaw(alert('Button1 clicked')) def ajaxFunc2(str: String) : JsCmd = { Log.info(Received + str) JsRaw(alert('Button2 clicked')) } def renderAjaxButtons(xhtml: NodeSeq): NodeSeq = { bind(ex, xhtml, button1 - SHtml.ajaxButton(Press Me, ajaxFunc1 _), button2 - buttonPress Me 2/button % (onclick - SHtml.ajaxCall(Str(Button-2), ajaxFunc2 _))) } } Which is in this template: lift:HelloWorld.renderAjaxButtons ex:button1 /br / ex:button2 /br / /lift:HelloWorld.renderAjaxButtons And is rendered thusly: button onclick=lift_ajaxHandler('F687305521434PIG=true', null, null); return false;Press Me/buttonbr / button onclick=(F687305521435R3K,lift_ajaxHandler ('F687305521435R3K=' + 'Button-2', null, null))Press Me 2/ buttonbr / Button 1 is find, but Button 2 causes FireBug to whine: F687305521435R3K is not defined onclick(click clientX=500, clientY=239)2 (line 2) [Break on this error] F687305521435R3K, lift_ajaxHandl...F687305521435R3K=Button-2, null, null); Does the second onclick look incorrect to you? -- Viktor Klang Senior Systems Analyst --~--~-~--~~~---~--~~ 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: A gap in my knowledge, JsCommands
Tyler, This call is malformed: button2 - buttonPress Me 2/button % (onclick - SHtml.ajaxCall(Str(Button-2), ajaxFunc2 _))) SHtml.ajaxCall returns a (String, JsCmd). The String is absolutely necessary (it will be actually) for GC). The call is doing the right thing and should not be patched. At some point when jQuery 1.4 comes out and fixes the namespace issue, the first parameter will need to go into a lift:gc attribute and the second will be the actual JavaScript command. So, please do not push your changes live. Thanks, David On Tue, Mar 31, 2009 at 8:57 AM, TylerWeir tyler.w...@gmail.com wrote: I'm wading into an area that I'm a bit unfamiliar with and not sure if I'm running in a bug. Snippet code: class HelloWorld { def ajaxFunc1() : JsCmd = JsRaw(alert('Button1 clicked')) def ajaxFunc2(str: String) : JsCmd = { Log.info(Received + str) JsRaw(alert('Button2 clicked')) } def renderAjaxButtons(xhtml: NodeSeq): NodeSeq = { bind(ex, xhtml, button1 - SHtml.ajaxButton(Press Me, ajaxFunc1 _), button2 - buttonPress Me 2/button % (onclick - SHtml.ajaxCall(Str(Button-2), ajaxFunc2 _))) } } Which is in this template: lift:HelloWorld.renderAjaxButtons ex:button1 /br / ex:button2 /br / /lift:HelloWorld.renderAjaxButtons And is rendered thusly: button onclick=lift_ajaxHandler('F687305521434PIG=true', null, null); return false;Press Me/buttonbr / button onclick=(F687305521435R3K,lift_ajaxHandler ('F687305521435R3K=' + 'Button-2', null, null))Press Me 2/ buttonbr / Button 1 is find, but Button 2 causes FireBug to whine: F687305521435R3K is not defined onclick(click clientX=500, clientY=239)2 (line 2) [Break on this error] F687305521435R3K, lift_ajaxHandl...F687305521435R3K=Button-2, null, null); Does the second onclick look incorrect to you? -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---