Ember.js Dynamic segment not working
I'm using Ember 1.0.0 and the latest build of Ember Data (beta), and I
have a route with a dynamic segment that isn't working.
I have defined the routes below:
PwdMgr.Router.map(function() {
this.resource("passwords", function(){
this.resource("password", {path: "/:password_id"}, function(){
this.route("edit");
});
});
}
In the template passwords.index I display a list of models like this:
{{#each}}
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>
{{#link-to 'password.index' this}}<span
class="glyphicon glyphicon-search"></span>{{/link-to}}
{{#link-to 'password.edit' this}}<span
class="glyphicon glyphicon-pencil"></span>{{/link-to}}
<span class="glyphicon glyphicon-remove" {{action
'edit' password}}></span>
</td>
</tr>
{{/each}}
I have two links, one that goes to the route password.index and one to the
route passwword.edit. I provide the model for the dynamic segment and the
handlebars creates the URL correctly (/passwords/1 and /passwords/1/edit).
My problem is that when I get to the URL /password/1 (or
/password/1/edit), the model is not a single object but an array of
objects.
Since I'm using the default pattern, as explained in the guides, I didn't
setup Route objects. But for debugging purposes I created a route object
for the password.index route. Here's what it looks like:
PwdMgr.PasswordIndexRoute = Ember.Route.extend({
model: function(params){
console.log(params);
return this.get('store').find('password',params.password_id);
},
setupController: function(controller, model){
console.log(model);
}
});
And here's my console log:
Object {} app.js (line 31)
<DS.RecordArray:ember435> { content=[3], store=<DS.Store:ember506>,
isLoaded=true, more...} app.js (line 35)
The empty object explains why I get an array of object but is there a
reason why the params variable is an empty object?
Thanks a lot
No comments:
Post a Comment