Maybe i lack imagination or its just my limited skill, i am looking at the
POSONLINE store from the web2py appliances and i was wondering if its
possible to avoid the page redirection everytime a person clicks on the
item to buy, everytime a person clicks on an item to buy the page changes
to the callback URL as the code below shows
*VIEW*
<table>
{{for p in products:}}
<tr>
<td><h2>{{=p.name}} - ${{=p.price}}</h2></td>
<td><img src="{{=URL('download',args=p.image)}}" height="100px"/></td>
<td>{{=MARKMIN(p.description)}}</td>
<td><span id="{{='item%s'%p.id}}">{{=session.cart.get(p.id,0)}}</span>
in cart - {{=A('add to
cart',*callback=URL('cart_callback'*,vars=dict(id=p.id,action='add')),target='item%s'%p.id,_class='button
pill')}}</td>
</tr>
{{pass}}
</table>
*CONTROLLER*
def cart_callback():
id = int(request.vars.id)
if request.vars.action == 'add':
session.cart[id]=session.cart.get(id,0)+1
if request.vars.action == 'sub':
session.cart[id]=max(0,session.cart.get(id,0)-1)
return str(session.cart[id])
How can i avoid the page switching to cart_callback page where it shows
count but still be able to choose whatever item i want as many times as i
want without leaving that page??
Regards
Mostwanted
--
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.