Ajax support of custom events

105 views
Skip to first unread message

coubeatczech

unread,
Jan 4, 2011, 7:02:37 PM1/4/11
to Lift
Hi,
in the SHtml object, there seems to be no support for custom events,
in functions like ajaxText. Looks like the only event that is caught
is blur. What if I want to listen to for example keypress? There seems
to be a "workaround", that is to write my own function, I've found
this via searching in this group:
def ajaxLiveText(value: String, func: String => JsCmd, attrs: (String,
String)*): Elem = {
S.fmapFunc(S.SFuncHolder(func)) {funcName =>
(attrs.foldLeft(<input type="text" value={value}/>)(_ %
_)) %
("onkeyup" -> makeAjaxCall(JsRaw("'" + funcName +
"=' + encodeURIComponent(this.value)")))
}
}
but still this is not an out of the box solution, things would even
get a little more complicated if I would like to listen to an custom
event like paste, it would be great to just specify the events which I
want to listen to in function parameters.
This is just an user feedback which I hope you like to have.
Jakub

David Pollak

unread,
Jan 4, 2011, 11:00:23 PM1/4/11
to lif...@googlegroups.com
Or:
def ajaxLiveText(value: String, func: String => JsCmd) = <input value={value} onkeyup={ajaxCall(JsRaw("this.value"), func)._2.toJsCmd}/>

We endeavor to make common tasks easy, there's a balance which is how to make sure the number of choices is not overwhelming.

I'm not sure if this method is common enough to strike the right place in the balance.

I'd much rather see a general purpose method (kind of like SHtml.onSubmit) that could be used to associate an ajaxCall with a broad range of form elements and events.


--
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.




--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Blog: http://goodstuff.im
Surf the harmonics

coubeatczech

unread,
Jan 5, 2011, 2:57:08 PM1/5/11
to Lift
David,
thanks for answering, there are 4 ajaxText methods in SHtml now. This
is actually a lot I think. There is parameter ignoreBlur, which is
kind of dealing with one event. It could be replaced with another
parameter list with repeated parameter either as tuple
(event,function)* or just event* and would not add another method to
the SHtml object if number of choices means number of methods in
object, not number of parameters in method.
I'm also not sure if need for this is common enough, based on search
in this group, there are at least two people who felt the need so
seriously, that they decided to post here. :-)
Jakub
> > liftweb+u...@googlegroups.com<liftweb%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/liftweb?hl=en.
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890

David Pollak

unread,
Jan 5, 2011, 11:22:59 PM1/5/11
to lif...@googlegroups.com

coubeatczech

unread,
Jan 6, 2011, 2:21:04 PM1/6/11
to Lift

Ivan Schuetz

unread,
Mar 2, 2013, 1:41:58 PM3/2/13
to lif...@googlegroups.com
Hi,

is there already a way to add easily onkeypress handler to ajaxText instead of onblur? I understand from this Thread that a generic functionality was implemented, but I can't find which one / how to use it.

I also found this: https://groups.google.com/forum/?fromgroups=#!topic/liftweb/QUPD49S37q4 But it's from 2010 and probably there's a better way now...


Thanks,
Ivan
> > <liftweb%2B...@googlegroups.com<liftweb%252Bunsubscribe@googlegroups.com>

Diego Medina

unread,
Mar 3, 2013, 6:35:54 PM3/3/13
to Lift
See my answer here
https://groups.google.com/d/topic/liftweb/g9-6dB6noac/discussion

look for liveajaxtext

Diego
>> > > <liftweb%2B...@googlegroups.com<liftweb%252Buns...@googlegroups.com>
> --
> --
> Lift, the simply functional web framework: http://liftweb.net
> 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
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to liftweb+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Diego Medina
Lift/Scala Developer
di...@fmpwizard.com
http://fmpwizard.telegr.am
Reply all
Reply to author
Forward
0 new messages