Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this.changedHandler = function(currentItem){
- console.log("Categoryamount before:");
- console.log(self.categoryAmount());
- // Maak categoryAmount leeg
- self.categoryAmount.removeAll();
- // Vul category amount weer
- for(var i = 0; i< self.cart().length; i++){
- var currentCartItem = self.cart()[i];
- // check if category already is in array
- var existingCategory = ko.utils.arrayFirst(self.categoryAmount(), function(item) {
- return currentCartItem.product().categoryId === item.categoryId();
- });
- if(existingCategory !== null){
- existingCategory.amount(existingCategory.amount() + currentCartItem.amount);
- }else{
- self.categoryAmount.push( new SelectedCategory(currentCartItem .product().categoryId, currentCartItem.amount));
- }
- }
- console.log("Categoryamount after:");
- console.log(self.categoryAmount());
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement