Search code examples
ember.jsember-old-router

Ember: Cannot read property 'enterStates' of undefined and textfield update


I have the following problem with ember.

I have a table with a set of datas. I have an event that returns me the current element of the table. Then it opens another view by transitioning into a new state and writes the selected table data in a textfield.

 click: function(e) {
        var element = $(e.target).closest("td");
        App.tee = element.text().trim();
        var router;
        router = this.get('controller.target.router');
        router.transitionTo('newRoute')

As you can see I have some other routes in my router as well. The last two routes(home and profile) are part of a nav-tab. They work perfectly beside I click on the table. Then i get the following error when i click on a tab: Uncaught TypeError: Cannot read property 'enterStates' of undefined

Ok i give it another try to explain what i wanted to do.

What i want to do is to create a table with some data (for example persons). When i click on a specific person in the table the corresponding table-data should be shown in the textfields that appear below. Whenever i click on another person the textfields below should change to the informations of the current clicked person in the table. When i click "New" Button a more detailed Tabview appears on the right side with some additional informations. I was playing around with ember and so far i just implemented some of the views and the routing. Im stucked as i have tried to implement the event that updates the textfield below the table. It updates once but after it has transitioned into the new state(newRoute) nothing happens. I know the code is very raw, but it is just a test to understand how this works in ember.


Solution

  • Ok the solution was easier than i thought. The problem was not the state changing. It was more a problem of how to access the data and how to effect the change of binded data. I realised too late that i needed to understand how the variable access works in Ember and what exactly the App.initialize() method does. So App.initialize() initializes all Controller classes in the router. If you want to access any variables within a controller you have to get the access over the router like

    {{view Ember.TextField valueBinding="App.router.tableController.person"}} 
    

    Secondly i wasnt familiar with the usage of the set and get methods in Ember and the difference between extend and create. I wondered before where ember instantiates my object. So my problem had nothing to do with states it was just a totally misunderstanding of the ember framework. Im a noob thats all.