Put information about the current page in the request.args dictionary. You could use the session, but if your user opens a second browser window it becomes difficult to keep track of which session data corresponds to which browser tab.
On Friday, November 14, 2014 8:37:25 PM UTC-5, Joe wrote: > > I am working on an app where the user can select items by clicking on a > button for each item on the index page. It works fine, except after each > item selected the user has to be redirected to index and ends up on the top > of the first page at item 1. Then the user has to go back each time and try > to find whatever page they were on before when they made the last > selection. How can I fix this so when the user selects the item, he is > redirected to the same page? > > def index(): > if len(request.args): > page=int(request.args[0]) > else: > page=0 > items_per_page=11 > limitby=(page*items_per_page,(page+1)*items_per_page + 1) > rows=db().select(db.post.ALL, limitby=limitby) > form = SQLFORM(db.post) > if form.process().accepted: > redirect() > selected = db(db.post.selected == True).select() > not_selected = db(db.post.selected == False).select() > return dict(form=form, selected=selected, not_selected=not_selected, > rows=rows, page=page, limitby=limitby,items_per_page=items_per_page) > > def select(): > id = request.vars.id > name = db(db.post.id == id).select().first() > if name: > name.selected = not name.selected > name.update_record() > return redirect(URL('index')) > -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.