I have the following setup. Each account can have multiple profiles.
app.js:
App.Router.map(function () {
this.resource("accounts", function () {
this.resource("profiles", {path: "/:account_id"})
})
});
App.Account = Ember.Object.extend({
findAll: function () {
// Ajax request to fetch data from the server
}
});
App.AccountsRoute = Ember.Route.extend({
model: function () {
return App.Account.findAll();
}
});
App.Profile = Ember.Object.extend({
findAll: function () {
// Ajax request to fetch data from the server
}
});
App.ProfilesRoute = Ember.Route.extend({
model: function () {
return App.Profile.findAll();
}
});
accounts.hbs:
{{#each model}}
{{#linkTo "profiles" tagName="li"}}
{{accountName}}
{{/linkTo}}
{{/each}}
{{outlet}}
profiles.hbs:
{{#each model}}
{{profileName}}
{{/each}}
However, this is not working. Whenever I click on one of the account names, nothing shows up in the outlet. And if I pass "this" in {{#linkTo "profiles" this tagName="li"}}, then I get an error message saying that Ember cannot loop through something that is not an Array. How would you go about linking from a parent route to a child route when they both have array controllers and the child template is displayed in the parent's outlet?
App.Account
hasprofiles: DS.hasMany('App.Profile')
? – chopperajaxError
function, like so:$(document).ajaxError(function(event, jqXHR, ajaxSettings, thrownError) { if (jqXHR.status === 401) { // error handling code here } });
– chopper