0
votes

I have a list of routes

App.Router.map ()->
@resource 'about'

@resource 'users', ->
    @resource 'repositories', path: '/:user_name/repositories'
    @route 'show', path: '/:user_name'

In my users show template i also have a view

{{#view App.RepositoriesView login=login}}
  <div class="show_repos_control">
      <span>Show Repos</span>
  </div>

  {{#if reposWasQuery}}
    {{#each repositories}}
      {{repo_name}}
    {{/each}}
  {{/if}}   
{{/view}}

with view class

App.RepositoriesView = Ember.View.extend({
  click: function(evt) {
    this.get('controller').send('showRepos', this.get('login'));
  }
});

view class code process into UsersShowController with code

App.UsersShowController = Ember.ObjectController.extend({
  reposWasQuery: false,
  actions:{
      showRepos: function(userName){
          this.set('reposWasQuery', true);
          this.set('repositories', jQuery.getJSON('/users/' + userName + '/repositories'));
    }
  }
})

Repository's data assigns as excpected, but in my view i can't dispay it. Getting error "#error some number"

1
what's the deal with the two return statements in your App.Router.map() function? You don't need any return statements in your map(). - Steve H.
If I were to guess I'd say it was a coffeescript to js, it kind of looks like it. - Kingpin2k
It might be usefull the post the complete error... The double return statements are very weird indeed. - Jordy Langen
i use coffeescript for my routes, this dirty code generate js2coffee fir me, sorry, i will update into coffee - Yegor Gorodov

1 Answers

1
votes

It is very strange to render a view for a controller and route with an open close block.

using {{render 'repositories' myRepositoriesArray}} instead will do the following:

  1. Render a new Repositories controller with the myRepositoriesArray as your data.
  2. Implicitly create a RepositoriesView.

You would need to put this code:

  <div class="show_repos_control">
      <span>Show Repos</span>
  </div>

  {{#if reposWasQuery}}
    {{#each repositories}}
      {{repo_name}}
    {{/each}}
  {{/if}}   

In the repositories template.

Ember is build with convention over configuration in mind. You should read up on the render helper and the things ember expects or create for you when rendering a route.