Skip to content

Commit

Permalink
The handlers of the product amount field were implemented.
Browse files Browse the repository at this point in the history
  • Loading branch information
cbdavide committed Oct 10, 2017
1 parent f520fe4 commit 41c9205
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions sales/static/js/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
$(document).ready(function() {

var $amount_field = $('#amount');

$('#add_product').on('click', function() {

var value = to_int($amount_field)
$amount_field.val(value + 1)

//TODO: No exceder la cantidad máxima de producto

})

$('#remove_product').on('click', function() {

var value = to_int($amount_field) - 1
$amount_field.val(value < 0 ? 0 : value)

})
})

function to_int($element) {
var value = $element.val()
value = value == '' ? 0 : parseInt(value)
return value
}


0 comments on commit 41c9205

Please sign in to comment.