Skip to content

Instantly share code, notes, and snippets.

@skilesare
Created February 21, 2012 02:23
Show Gist options
  • Save skilesare/1873086 to your computer and use it in GitHub Desktop.
Save skilesare/1873086 to your computer and use it in GitHub Desktop.
Invalidating cached property
GS.cMenu = Em.Object.create
searchTerm : ""
menu: null
restaurantLocation: null
cart: Ember.A([])
addToCart: (orderItem,control) ->
newOrderItem = {orderItem: orderItem, id: guidGenerator()}
newA = @cart
newA.pushObject newOrderItem
@set 'GS.cMenu.cart',newA
newOrderItem
GS.vMenuItem = Em.View.extend
templateName: 'tMenuItem'
cartBinding: "GS.cMenu.cart"
cartItems: (->
return @cart.filter ((obj) ->
return @content.MenuItemID is obj.orderItem.MenuItemID) , this
).property('cart').cacheable()
priceMoney: (->
@content.Price.formatMoney 2, '.', ','
).property()
addItem: ->
newItem = GS.cMenu.addToCart @content, this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment