1
votes

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.

2
I'd recommend you to update to the last ember commit if possible (the router has completely changed). If you can't, would it be possible to create a jsfiddle of your application ? From what I see here, nothing seems wrong :s - sly7_7
well to be honest i dont understand the new router. The tutorial on the ember site is not made for newbies. The tutorial for the old router was much more detailed, so as there no really good guides for the router,I have to use the old. - Alexander Hauer
Ok, no problem at the moment. I would be pleased to help you to migrate your actual app example if you provide me the current one as a fiddle :) - sly7_7
so here is Jsfiddle - Alexander Hauer
Ok, I'm not able to see the Navbar (probably due to the lack of backbone dep for bootstrap.js). I will work on it this evening. - sly7_7

2 Answers

1
votes

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.

0
votes

Ok, this is the first shot of the answer.

  • I think the main issue is just a typo gotoHome instead of goToHome in the template.
  • By the way I get rid of some deprecation warnings by using <button {{action }}></button> instead of Ember.Button.
  • There is some other warnings when I click on the table, because you are referencing some properties which don't exist.

here is the corresponding fiddle: http://jsfiddle.net/Sly7/rKw9A/25/

Since I don't understand how it should work exactly, I'm not sure of the overall behavior. I let you explain me the flow (by editing the question please). Any other comment is welcome :)