Skip to content

Instantly share code, notes, and snippets.

@SeanRoberts
Created November 5, 2014 20:40
Show Gist options
  • Save SeanRoberts/89be5549e9c012ced68c to your computer and use it in GitHub Desktop.
Save SeanRoberts/89be5549e9c012ced68c to your computer and use it in GitHub Desktop.
# Model
OH.Itinerary = DS.Model.extend
uniqueKey: DS.attr('string')
listings: DS.hasMany('listing')
remove: (listing) ->
if confirm("Remove #{listing.get('address1')} from your itinerary?")
@get('listings').removeObject(listing)
$.ajax
url: "/api/v1/itinerary_listings/#{@get('uniqueKey')}.json"
data: { listing_id: listing.get('id') }
method: 'DELETE'
# itinerary controller
actions:
remove: (listing) ->
@get('model').remove(listing);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment