On Feb 7, 3:12 pm, "mr.freeze" <nat...@freezable.com> wrote: > Nice! I like this but I think it needs a few more tweaks. Can you > modify it to allow the arrow keys to select an item? Also, when you > clear the input after typing something, all of the options show.
Yes it can be done. It is on my to do list. > > I personally think that javascript should be used more in the > framework (with proper attention paid so that things degrade > gracefully when it's off). Something like auto-completion is just going to break if jQuery is not present. I am not sure if it is possible to make degrade gracefully. > > On Feb 7, 2:11 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > How about we change IS_IN_DB so that, if the number of referenced > > records exceeds a maximum the auto complete widget is on by default? > > > Massimo > > > On Feb 7, 1:02 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > I do not know that. I am still playing with it... > > > > On Feb 6, 11:40 pm, Jason Brower <encomp...@gmail.com> wrote: > > > > > I have my current autocomplete but it doesn't do öäå in a search. Does > > > > this handle that? > > > > Best Regards, > > > > Jason > > > > > On Sat, 2010-02-06 at 12:30 -0800, mdipierro wrote: > > > > > People say there is some magic in web2py. > > > > > Here is some real magic now in trunk that I am sure you have never > > > > > seen. > > > > > > Caveats: > > > > > 0) requires latest trunk (bzr 1603, hg 175:e42b559254f6) > > > > > 1) this is an experiment, not sure it is a good idea > > > > > 2) this is the first function in web2py that REQUIRES jQuery > > > > > 3) works but I am not yet convinced it should stay there > > > > > 4) even if it stays, I am sure the API should stay > > > > > > Example: > > > > > > ### assume this model > > > > > db.define_table('target',Field('name')) > > > > > if not db(db.target.id>0).count(): > > > > > db.target.insert(name="Klingon") > > > > > db.target.insert(name="Romulans") > > > > > db.target.insert(name="Borg") > > > > > db.target.insert(name="Borg2") > > > > > db.define_table('photon_torpedo',Field('target',db.target)) > > > > > > ### assume this action in controller default.py > > > > > def launch(): > > > > > db.photon_torpedo.target.represent=lambda target: target.name > > > > > return dict(new_torpedo=crud.create(db.photon_torpedo), > > > > > launched_torpedos=db().select(db.photon_torpedo.ALL)) > > > > > > So far nothing new. > > > > > > Now append to the model or insert at top of controller the following: > > > > > > from gluon.sqlhtml import AutocompleteWidget > > > > > db.photon_torpedo.target.widget=AutocompleteWidget(request,db.target.name,db.target.id) > > > > > > No need to define any callback action (there is no callback action!) > > > > > No plugin required (perhaps some optional css to style). > > > > > No js coding required. > > > > > Applies to existing apps, including those that use custom forms. > > > > > > Let's see who can figure out how it works! > > > > > > Massimo > > -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.