1

i'm having some trouble designing an EmberJS layout. I have a view divided in two parts :

  • a content library on the left
  • a playlist editor on the right

Currently, those two elements share the same controller.

I can't figure how to use two different controllers for those two sides to be able to re-use the content library in other views or even having a view with two playlist editors.

My root view looks like this so far :

<script type="text/x-handlebars" data-template-name="playlists">
    <div id="library">{{template library}}</div>
    <div id="playlistEditor">{{template playlisteditor}}</div>
</script>

I saw docs about the {{control}} helper, but it is unstable and i'm not sure this is what i'm looking for.

Thanks !

4

1 回答 1

1

好的,我找到了答案,我不得不使用{{render}}助手,就像这样:

<script type="text/x-handlebars" data-template-name="playlists">
    <div id="library">{{render "library" library}}</div>
    <div id="playlistEditor">{{render "playlisteditor" playlist}}</div>
</script>

然后,在我的路线中:

App.PlaylistsRoute = Ember.Route.extend({
  setupController: function(controller) {
     controller.set('playlist', playlist);
     controller.set('library', library);
  }
});

然后,这个 EmberJS 将自动连接App.PlaylisteditorControllerApp.LibraryController和 视图playlisteditorlibrary. 惊人的。

于 2013-04-25T10:31:55.817 回答