I have a CompanyRoute, CompanyArrayController, and template defined for resource:
<script type="text/x-handlebars" id="companies">
<div class="col-md-2">
<table class="table table-striped table-bordered">
<thead>
<tr><th>Companies</th>
<th>
<div class="pull-right">
{{#if isCreating}}
{{partial 'companies/create'}}
<button {{action 'create'}} class="btn btn-default">Done</button>
{{else}}
<button {{action 'create'}} class="btn btn-default">Create</button>
{{/if}}
</div>
</th>
</tr>
</thead>
<tbody>
{{#each}}
<td colspan="2">
{{#link-to 'company' this}}{{name}}{{/link-to}}
</td>
{{/each}}
</tbody>
</table>
</div>
{{outlet}}
</script>
The routes are defined as resource.
this.resource('companies', function() {
this.resource('company', {path:':company_id'});
});
And the company is rendered accordingly in the projects outlet.
But for the create form within this template (defined by the partial 'companies/create'), I need this to be managed by the ObjectController (ie: ProjectNewController) for the Project. The reason is that the ArrayController (CompaniesController) isn't well suited for keeping track of a single object because I find there can be many property name collisions and overall introduces redundancy. I have "needs" controller specified on the ArrayController (CompaniesController). I need to have this create form managed by the ProjectNewController, and not by the ProjectsController.
I can manually specify the target on the action to the controller, but this isn't optimal solution. I've also tried to use the "with controllers.etc..." tag around the form with no avail.
Thanks for any pointers or example.
(please note, I'm not using ember data)
Aucun commentaire:
Enregistrer un commentaire