1

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.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Alexander Hauer
  • 73
  • 2
  • 10
  • 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 Jan 15 '13 at 12:58
  • 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 Jan 15 '13 at 14:01
  • 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 Jan 15 '13 at 14:02
  • 1
    so here is [Jsfiddle](http://jsfiddle.net/rKw9A/7/) – Alexander Hauer Jan 15 '13 at 14:46
  • 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 Jan 15 '13 at 15:04
  • there is no navbar. Im sorry maybe i couldnt express myself correctly. There is only tab field on the right side but the problem real problem is that the textfield will not be updated when i click on it. – Alexander Hauer Jan 15 '13 at 15:10
  • Ok, playing a bit, I encounter "Uncaught Error: <.Router:ember610> could not respond to event gotoHome in state root.newRoute.canvas.profile." It seems like you are in a bad state in order to call the transitionTo. I'm sorry, I'm at the office, I will work on this this evening, probably I will give you an answer with the new router, because it seems to me the aplication will be simplified :). I may also fix this one explaining exactly what's wrong, and then you can compare :) – sly7_7 Jan 15 '13 at 15:19

2 Answers2

1

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.

Alexander Hauer
  • 73
  • 2
  • 10
0

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 :)

sly7_7
  • 11,961
  • 3
  • 40
  • 54