samedi 10 janvier 2015

ember - need template to show records for nested route

it seems that i am not setting up my model hook in my router correctly because my data is rendering in the template. but maybe there is something else that i'm missing


here is my router



Router.map(function() {
this.resource('movies', function() {
this.route('show', { path: ':movie_id'}, function() {
this.resource('rewrites', function() {
this.route('show', { path: ':id'});
this.route('new');
this.route('edit');
});
});
this.route('edit', { path: ':movie_id/edit'});
this.route('new');
});
});


in my index template for rewrites below, templates/rewrites/index.hbs, i need to show all the rewrites that are for one particular movie



{{outlet}}

{{link-to 'Add a New Rewrite' 'rewrites.new'}}

<table class="table table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Script</th>
<th>Author</th>
<th></th>
</tr>
</thead>
<tbody>
{{#each rewrite in movie}}
<tr>
<td>
{{rewrite.name}}
</td>
<td>{{rewrite.script}}</td>
<td>{{rewrite.author}}</td>
<td>{{link-to 'Edit this Rewrite' 'rewrites.edit' this}}</td>
<td><a href="#" {{action 'delete' rewrite}}>Delete</a></td>
</tr>
{{/each}}
</tbody>
</table>


my model setup in my route, routes/rewrites/index.js, is



model: function() {
var movie = this.modelFor('movies.show');
return this.store.findAll('rewrite', { movie:movie });
},


i've tried many things for the model, also tried



return this.store.findAll('rewrite');


either way the template is found and rendered, but there is no data after creating rewrite 2, i've then tried



return this.store.find('rewrite', 2);


and that does not render any data either.





Aucun commentaire:

Enregistrer un commentaire