Created
July 9, 2013 17:48
-
-
Save JumboLove/5959525 to your computer and use it in GitHub Desktop.
Increment/Decrement Button
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
| jQuery(".cart .quantitybtn").click(function(){ | |
| var productID = jQuery(this).attr("data-pid"); | |
| var inputField = jQuery(".cart .quantitycolumn input[data-pid=" + productID + "]"); | |
| var oldValue = inputField.val(); | |
| if(jQuery(this).hasClass("plus")){ | |
| var newValue = oldValue < app.cart.maxNumber ? parseInt(oldValue) + 1 : oldValue; | |
| } else { | |
| var newValue = oldValue > app.cart.minNumber ? parseInt(oldValue) - 1 : oldValue; | |
| } | |
| //Set the new value and trigger a change | |
| inputField.val(newValue); | |
| if(newValue !== oldValue){ | |
| inputField.trigger("change"); | |
| } | |
| return false; | |
| }); | |
| jQuery(".cart .quantityinput").change(function(){ | |
| console.log("changed"); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment