mercredi 3 juin 2015

How do I render the new route of a child resource into the application sidebar outlet?

My project is ember.js using ember-cli and ES6 import methods.

This question is about rendering the new route for the child resource dataset into the application {{ outlet 'sidebar' }} while other routes on dataset (show) render into {{ outlet 'main' }}

application.hbs

<div class="col-xs-8">
  Outlet Main
  {{liquid-outlet "main"}}
</div>
<div class="col-xs-4">
  Outlet Sidebar
 {{liquid-outlet "sidebar"}}
</div>

router.js

this.resource('organizations', function() {
    this.route('new');
    this.resource('organization', { path: '/:organization_id' }, function() {
      this.route('edit');
      this.resource('datasets', function() {
        this.route('new');
        this.resource('dataset', { path: '/:dataset_id' }, function() {
          this.route('edit');
        });
      });
    });
  });

routes/organization.js:

import Ember from 'ember';

export default Ember.Route.extend({
  renderTemplate: function() {
    //render into application so organizations template doesn't show
    this.render('organization', {
      into: 'application',
      outlet: 'main',
      controller: 'organization'
    });
    // **** Not working but roughly what I want to do
    this.render('organization.datasets.new', {
      into: 'application',
      outlet: 'sidebar',
      controller: 'organization.datasets.new'
    });
    // ******
  }
});

Currently I get this error when attempting this code:

Error while processing route: types.index You passed `controller: 'organization.datasets.new'` into the `render` method, but no such controller could be found. Error: You passed `controller: 'organization.datasets.new'` into the `render` method, but no such controller could be found.

My understanding is that any child resource routes should be determined in the parents route. True? How do I get ember to recognize the controller? I'm guessing my syntax is wrong... Thanks for the help.




Aucun commentaire:

Enregistrer un commentaire