in the view links add the page and element id:

{{=A('Select', _id = i.id, _class="btn btn-danger",_href=URL("select", args=
i.id, vars=dict(id=i.id,page=page)))}}

{{elif i.selected:}}
{{=A('Selected', _id = i.id, _class="btn btn-info",_href=URL("select", args=
i.id, vars=dict(id=i.id, page=page <http://i.id/>)))}}


in action select() do:
redirect(URL('index#' + request.vars.id, args=[request.vars.page]))

no return needed!

Actually you could resort to using AJAX for instance by using
{{=A('Selected', _id = i.id, _onclick="jQuery.get(" +URL('select', 
args=[i.id]).... ...
and use jQuery itself to manipulate the css class of the button itself




Il giorno giovedì 20 novembre 2014 04:59:11 UTC+1, Joe ha scritto:
>
> @Massimo, Thanks very much Massimo. I am trying to find a way to redirect 
> the user to the page where the user clicks on the select button to select 
> an item. The user might be on page 2 or page 3 page 4 or any other page 
> when he selects the item. How can I redirect the user to the same page he 
> is on when making the selection.
>
> This is the View for the Controller code I posted:
>
> {{extend 'layout.html'}}
> {{for i in rows:}}
> <div class="well">
> <h5>{{=i.name}}</h5>
> {{if not i.selected:}}
> {{=A('Select',_class="btn btn-danger",_href=URL("select",args=i.id, 
> vars=dict(id=i.id)))}}
> {{elif i.selected:}}
> {{=A('Selected',_class="btn btn-info",_href=URL("select",args=i.id, 
> vars=dict(id=i.id)))}}
> {{pass}}
> </div>
> {{pass}}
> <br><br>
> {{if page:}}
> <a href="{{=URL(r=request, args=[page-1])}}">previous</a>
> {{pass}}
> {{if len(rows)>=items_per_page:}}
> <a href="{{=URL(r=request, args=[page+1])}}">next</a>
> {{pass}}
>
> On Thursday, November 20, 2014 11:38:05 AM UTC+8, Massimo Di Pierro wrote:
>>
>> URL('index',args=(2)) will give you page #2.
>>
>>
>> On Monday, 17 November 2014 22:59:16 UTC-6, Joe wrote:
>>>
>>> Thanks Cliff, I've been trying to do that but I didn't succeed. I would 
>>> appreciate if you could send an example on how to put the current page info 
>>> in the request.args dictionary.
>>>
>>> On Tuesday, November 18, 2014 12:37:09 PM UTC+8, Cliff Kachinske wrote:
>>>>
>>>> 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.
>>>>
>>>>
>>>>

-- 
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.

Reply via email to