Hi,
I am adapting the search with ajax example of a beta of the book,
Massimo sent me some time.
In controller:
def search():
"an ajax wiki search page"
return dict(form=FORM(INPUT(_id='keyword',
_onkeyup="ajax('bg_find',['keyword'],'target');")),
target_div=DIV(_id='target'))
def bg_find():
"an ajax callback that returns a <ul> of links to wiki pages"
pattern='%'+request.vars.keyword.lower()+'%'
mypages=db(db.page.title.lower().like(pattern))\
.select(orderby=db.page.title)
items=[A(row.title,_href=URL(r=request,f=show,args=[row.id])) \
for row in mypages]
return UL(*items).xml()
the code for the view "default/search.html"
{{extend 'layout.html'}}
<h1>Search wiki pages</h1>
[ {{=A('listall',_href=URL(r=request,f='index'))}}]<br/>
{{=form}}<br/>
{{=target_div}}
It happens, and I understand that this should happen, that as bg_find
not have a definite view, the result is displayed with the default
view. This is contrary to what the book shows.
Or maybe I'm doing something wrong.
Jose
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" 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
-~----------~----~----~----~------~----~------~--~---