I'm a biologist, very much not a programmer, I wanted to make some web
based databases for the lab and found web2py and I've been having a lot of
fun and success learning. But I have a problem that I really do not
understand. I have a lot of zebrafish (zebrafish are remarkably good models
of human disease) and we breed them. One male and one female. I thought I
would search for one parent using the ajax search found in the book, then
search for the next parent.
I thought I was a genius when I copied and pasted successfully and could
search for one parent. But when I go to search for the next parent a
problem happens. Instead of the list of parents showing up under the search
field, i.e. in the target div, it seems a new version of the page opens as
an iframe in the div.
I've tried all kinds of goofy things and nothing so far allows me to get a
second list of ajax found rows. I'm not sure what code to include to help
out. I've tried to separate each step into different functions in the
controller, I can reproduce this in the images blog example with the
controller functions pasted below.
I'm clearly missing something obvious, any help appreciated.
Even more helpful than correcting my problem would probably be an
explanation of how I have gone so wrong! I generally have trouble figuring
out where my errors are which is quite frustrating to me.
Many thanks
def start_selection():
form = FORM(INPUT(_id='keyword',_name='keyword',
_onkeyup="ajax('first_selection_callback',
['keyword'], 'target');"))
target_div=DIV(_id='target')
return dict(form=form, target_div=target_div)
def first_selection_callback():
query = db.image.title.contains(request.vars.keyword)
images = db(query).select()
links = [A(a.title, _href=URL('next_select', args=[a.id, a.title])) for
a in images]
return UL(*links)
def next_select():
form2 = FORM(INPUT(_id='keyword2',_name='keyword2',
_onkeyup="ajax('next_selection_callback',
['keyword2'], 'target2');"))
target_div2=DIV(_id='target2')
return dict(form2=form2, target_div2=target_div2)
def next_selection_callback():
query = db.image.title.contains(request.vars.keyword)
images = db(query).select()
links = [A(b.title, _href=URL('index', args=[b.id, b.title])) for b in
images]
return UL(*links)
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.