Denes,
Thanks for pointing me in the right direction. This is what I have got
so far:
The following functions:
def ctl_that_returns_plaatsnaamlist():
if not request.vars.plaatsnaam: return ‘’
pattern=request.vars.plaatsnaam.capitalize()+’%’
selected=[row.plaatsnaam for row in db(db.adres.plaatsnaam.like
(pattern)).select(db.adres.plaatsnaam,distinct=True)]
return ‘’.join([DIV(k,_onclick=”$(‘#plaatsnaam’).attr
(‘value’,’%s’)”%k).xml() for k in selected])
def byplace():
response.view=’clubs/view.html’
response.functionname=T('Club locator op plaats')
form=form_factory(SQLField('plaatsnaam',
label='Type eenplaatsnaam',
requires=IS_NOT_EMPTY(),
widget=lambda self, value:TAG[''](
INPUT(_class="string",
_id="plaatsnaam",
_name="plaatsnaam",
_type="text",
_onkeyup="ajax('ctl_that_returns_plaatsnaamlist',
['plaatsnaam'],'plaatsnaamlist')"),
DIV(_id="plaatsnaamlist")
)))
if form.accepts(request.vars,session):
response.message=’Geen match op plaatsnaam’
clubs=db((db.bedrijf.id==db.adres.bedrijf)&
(db.bedrijf.id==db.bedrijfbranche.bedrijf)&\
(db.adres.plaatsnaam==request.vars.plaatsnaam)&
(db.adres.adressoort==2)&\(db.bedrijfbranche.branche==2))\
.select
(db.bedrijf.id,db.bedrijf.bedrijfsnaam,db.bedrijf.ranking,db.adres.straatnaam,
\
orderby=db.bedrijf.ranking|db.bedrijf.bedrijfsnaam)
else:
response.message='Formuleer een zoekopdracht'
clubs=[]
return dict(form=form,clubs=clubs)
The byplace() function resides in a clubs controller, together with
byactivity and byfacility functions which are similar in
functionality. Since I also need the auto-complete field in an event
list controller I wonder where to put the
ctl_that_returns_plaatsnaamlist() function. In my models I have got a
db.py with table definitions and a navigation.py with application and
controller menus, so, is it a good idea to create a .py file in my
models and put the ctl_that_returns_plaatsnaamlist() function in
there?
Furthermore there are two lines of code I do not understand, could you
please explain what their parameters are and what happens when they
are executed.
return ‘’.join([DIV(k,_onclick=”$(‘#plaatsnaam’).attr
(‘value’,’%s’)”%k).xml() for k in selected])
_onkeyup="ajax('ctl_that_returns_plaatsnaamlist',
['plaatsnaam'],'plaatsnaamlist')"),DIV(_id="plaatsnaamlist")
In the web2py manual, Massimo mentions a jQuery auto-complete plugin,
at the jQuery site I found 4 of them, however, I haven't got a clue
whether I am better of using a plugin than using a widget , what do
you think?
Annet.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---