We have a template that passes a related reference to a cart_item from the item.
- The ITEM below has a belongsTo reference to cart_item.
- It seems cart_item is not really loaded here, and requires to be asynchronously loaded with a “then”
How can I abstract this to work with both passed references from item.cart_item and pass in a cartItem record directly?
Passing in a loaded cartItem currently breaks with TypeError: cartItem.then is not a function
.
{{#if item.cart_item}}
<div {{action "changeQuantityOfCartItem" item.cart_item 1 bubbles=false}}></div>
{{/if}}
/**
* Change quantity of item in cart, through cart item
* @param object the cartItem to change
* @param int changeWith the amount we want to change with
* @method changeQuantityOfCartItem
*/
changeQuantityOfCartItem: function(cartItem, changeWith) {
// Do someting as this seems to be a promise in our set case
// BUT HOW WOULD I WORK WITH THE BELOW IF IT'S A REAL PASSED cartItem?
cartItem.then(function(item){
// MODIFY cartItem HERE!
//
//
}.bind(this));
},