On Wednesday, March 9, 2016 at 6:20:38 PM UTC-5, Ron Chatterjee wrote: > > I have a pagination that is called by multiple controller, I want to call > the pagination function by passing few arguments based on my display > requirement and get the output variables rather than keep typing these > lines all the time to all the controllers. > > > def pagination(): > if len(request.args): page=int(request.args[0]) > else: page=0 > items_per_page=int(request.args[1]) > limitby=(page*items_per_page,(page+1)*items_per_page+1) > return dict(limitby = limitby,page=page,items_per_page=items_per_page) > > > def item_list(): > > items_per_page= 25;#25 for this page > output = LOAD('default','pagination.load', args=[request.args, > items_per_page], ajax=True, ajax_trap=True ) > > This don't seem to call the pagination and how to access limitby, > items_per_page etc...? >
First, it should be: args=request.args + [items_per_page] Otherwise, you are creating a list whose first item is another list. Also, ajax_trap is irrelevant when ajax=True. What do you do with "output"? Are you including it in the item_list view? What is in the pagination.load view? Are you sure you want "pagination" to be an Ajax component, or do you just want it to be a helper function that returns some pagination parameters given some inputs? If the latter, maybe move it to a model, and just use it to return the parameters you need: def item_list(): ... pagination = pagination() ... Anthony -- 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.