ReferenceError: transitionTo is not defined


#1

Hi.I am tying to save a post object.

savePost(newPost){
newPost.save().then(()=>transitionTo('posts.index'));

I get back the error in the title." transitionTo is now defined".I have tried curly braces syntax too. And it is not only after “save()”.I can’t do transition.Always this error.Please send help ^-^


#2

I suppose, the savePost(newPost) is an action in a route handler (in a route file). A simple this is missing.

actions: {
  savePost(newPost) {
    newPost.save().then( () => this.transitionTo('posts.index') );
  }
}

transitionTo is an Ember.Route method: api doc

So, the this refers back to the Ember.Route class.


#3

Yes yes yes.Thank you so much.Sometimes those typos ruin everything ha :slight_smile:


#4

Btw you are my hero.Great tutorial.I want to thank you for that Great Resource.I have never seen any other like that.Ember 2.9, covers actions, components, and some addons.Also FireBase. :slight_smile: I feel like i am talking to my hero right know ^.^


#5

Thank you. :smiley: I’m glad you learned a lot, however the real Hero here is You, because you learned a new framework, you can build web applications quickly and I’m sure you will help to other developers soon. Keep up the great work! :smiley:


#6

I really do hope to be able to help beginners like my self right now.:slight_smile: But i have a long way to do so. May i ask you a small but important question via special message ?


#7

Yes of course, don’t hesitate.