Skip to content

Instantly share code, notes, and snippets.

@dbarrionuevo
Created May 5, 2016 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbarrionuevo/f25099e48eba21883060534a719f6546 to your computer and use it in GitHub Desktop.
Save dbarrionuevo/f25099e48eba21883060534a719f6546 to your computer and use it in GitHub Desktop.
// Update subtotal and total amounts on checkout, considering fees
GrowDough.Behaviors.UpdateTotal = Essential.Behavior.extend({
init: function() {},
events: {
'keyup': 'updateSubtotal'
},
updateSubtotal: function(e, force) {
// Keys and events on which the behavior has to update totals
var isNumber = e && ( (e.which >= 48 && e.which <= 57) || (e.which >= 96 && e.which <= 105) ),
isBackSpace = e && e.which == 8,
isDelete = e && e.which == 127,
isClick = e && e.which == 1;
if ( isNumber || isBackSpace || isDelete || isClick || force ) {
// Update totals
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment