I have some html:
{{for i, (product_id, qty, total_price, product, options) in
enumerate(order):}}
<td><input class="input_quantity value" name="product_quantity_one"
id="value_pro_1" type="text" value="{{=qty}}" /></td>
<td><div class="minus" id="min_pro_1">-</div></td>
<td><div class="plus" id="plus_pro_1">+</div></td>
I have a js function that takes min_pro_1 and plus_pro_1 and allows them to
decrement of increment value_pro_1. So they're just buttons a user can
click and the product quantity goes up and down. Well, the js I have needs
each quantity field to have a unique id (imagine that) but my {{for i}}
python just creates each item with the same id. How do I increment these
ids to ensure valid code and proper functioning of the js?
So item two would be:
<td><input class="input_quantity value" name="product_quantity_one"
id="value_pro_2" type="text" value="{{=qty}}" /></td>
<td><div class="minus" id="min_pro_2">-</div></td>
<td><div class="plus" id="plus_pro_2">+</div></td>
And so on. The function I've got in my controller now is:
def increment(self,key,value=1):
self.locker.acquire()
try:
if key in self.storage:
value=self.storage[key][0]+value
self.storage[key]=(value)
except BaseException, e:
self.locker.release()
raise e
self.locker.release()
return value
And I figured I could do something like:
{{for i, (product_id, qty, total_price, product, options) in
enumerate(order):}}
<td><input class="input_quantity value" name="product_quantity_one"
id="value_pro_{{=increment}}" type="text" value="{{=qty}}" /></td>
<td><div class="minus" id="min_pro_{{=increment}}">-</div></td>
<td><div class="plus" id="plus_pro_{{=increment}}">+</div></td>
--