Created
November 19, 2013 00:59
-
-
Save adamthedeveloper/7538338 to your computer and use it in GitHub Desktop.
Increment / Decrement coffeescript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.ChangeQuantity ||= {} | |
ChangeQuantity.load = ()-> | |
$("input.change-quantity").click((evnt)-> | |
evnt.preventDefault() | |
quantityField = $(this).parent().find('input.quantity') | |
currVal = parseInt(quantityField.val()) | |
if $(this).val() == '+' | |
quantityField.val(currVal+=1) | |
else | |
if currVal > 0 | |
quantityField.val(currVal-=1) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's the html: