1
votes

What is the proper way to call a route from the controller or view. For instance I have a table with many rows. Every row View has a click method that should call the router. It doesn't work I am having trouble navigating the app from the controller or view.

Here is an example: http://jsfiddle.net/arenoir/Cs938/

App.TableView = Ember.CollectionView.extend({
  tagName: 'table',
  contentBinding: 'controller.rows',
  itemViewClass: Ember.View.extend({
    tagName: 'tr',
    template: Ember.Handlebars.compile("<td>{{view.content.name}}"),
    click: function(){
      var router, tab;
      router = this.get('controller.target.router');
      tab = this.get('content.id');
      router.goTab(tab);
    }
  })
});

The following post is helpful. EmberJS: How to transition to a router from a controller's action.

1

1 Answers

6
votes

That is the current implementation of the Transitioning Logic in your view:

      click: function(){
          var router, tab;
          router = this.get('controller.target.router');
          tab = this.get('content.id');
          router.goTab(tab);
      }

Change it to this implementation:

  click: function(){
      var router, tab;
      router = this.get('controller.target.router');
      tab = this.get('content.id');
      router.transitionTo(tab);
  }

This fixes the fiddle. But from your example it is not clear, why you want to do trigger Transitions in your View. Statemanagement should always happen in the Router. Another awkward thing is that you get your rows from the ApplicationController. Why don't u use an ArrayController. So from my point of view, there seem to be some things in the wrong place.