Skip to content

Instantly share code, notes, and snippets.

@emirotin
Created May 20, 2013 18:09
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 emirotin/5614067 to your computer and use it in GitHub Desktop.
Save emirotin/5614067 to your computer and use it in GitHub Desktop.
save Ember model (ember-restless) and redirect to its route
saveAndRedirect = (redirectTo) ->
->
model = @get('model')
model.saveRecord()
done = =>
model = model.constructor.find model.id
model.on 'didLoad', =>
@transitionToRoute redirectTo, model
model.on 'didCreate', done
model.on 'didUpdate', done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment