hi,
i've tried to learn ajax callback using form(), but it's not work (no error
occured), did anyone know the solution for this?
thank you very much before
here is my code:
*#controller*
def order_callback():
id=int(request.vars.id)
quantity=int(request.vars.quantity)
if request.vars.action=='add':
session.order[id]=session.order.get(id, 0)+quantity
return str(session.order[id])
def product():
rows=db((db.product.quantity>0) & (db.product.is_active ==
True)).select(limitby=limitby, orderby=~db.product.id, cache=(cache.ram,
10))
form=FORM(INPUT(_id='sale_quantity', _name='quantity', _type='text',
_size='3', requires = IS_NOT_EMPTY(error_message='cannot be empty!')))
return dict(rows=rows, form=form)
*#view*
*testing 1** not work no error occured:*
{{for i,row in enumerate(rows):}}
{{if i==items_per_page: break}}
<tr>
<td>{{=SPAN(row.product_name)}}
</td>
<td>{{=SPAN(session.order.get(row.id,0), _id="item%s"%row.id),
T(' In Order')}}
</td>
<td>{{=form}}
</td>
* <td>{{=A('Order Now!!!', callback=URL('order_callback',
vars=dict(id=row.id, quantity=request.vars.quantity, action='add')),
target='item%s'%row.id, _title='Add the Order', _class='btn btn-navbar')}}*
* </td>*
</tr>
{{pass}}
*
testing 2 not work no error occured:*
{{for i,row in enumerate(rows):}}
{{if i==items_per_page: break}}
<tr>
<td>{{=SPAN(row.product_name)}}
</td>
<td>{{=SPAN(session.order.get(row.id,0), _id="item%s"%row.id),
T(' In Order')}}
</td>
<td>{{=form}}
</td>
* <td>{{=A('Order Now!!!', callback=URL('order_callback',
vars=dict(id=row.id, quantity=form.vars.quantity, action='add')),
target='item%s'%row.id, _title='Add the Order', _class='btn btn-navbar')}}*
* </td>*
</tr>
{{pass}}
*
testing 3 not work no error occured:*
{{for i,row in enumerate(rows):}}
{{if i==items_per_page: break}}
<tr>
<td>{{=SPAN(row.product_name)}}
</td>
<td>{{=SPAN(session.order.get(row.id,0), _id="item%s"%row.id),
T(' In Order')}}
</td>
<td>{{=form}}
</td>
* <td>{{=A('Order Now!!!', callback=URL('order_callback',
vars=dict(id=row.id, quantity='quantity', action='add')),
target='item%s'%row.id, _title='Add the Order', _class='btn btn-navbar')}}*
* </td>*
</tr>
{{pass}}
--
---
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/groups/opt_out.