Really stumped on this one..hopefully I can explain the issue clearly.
I'm loading multiple models in the EditRoute and displaying data from the artist model perfectly. Artist Genres is a related model and also displays fine in the template.
Model:
var attr = DS.attr,
belongsTo = DS.belongsTo,
hasMany = DS.hasMany;
App.Artist = DS.Model.extend({
description: attr(),
groupname: attr(),
artist_genre: hasMany('artistGenre', { embedded: 'always' }),
});
App.ArtistGenre = DS.Model.extend({
name: attr(),
});
App.Genre = DS.Model.extend({
name: attr(),
displayorder: attr(),
})
Route:
App.EditRoute = Ember.Route.extend({
model: function(params) {
return Ember.RSVP.hash({
artist: this.store.find('artist',App.CurrentProfile.id),
genre: this.store.find('genre'),
});
},
setupController: function(controller, model) {
controller.set('artist', model.artist);
}
});
Controller:
App.EditBasicInfoController = Ember.ObjectController.extend(App.ArtistEdit,{
artist: null,
genre: null,
});
Template:
List OF Artist Genre (Related model):
{{#each genre in artist.artist_genre}}
- {{genre.name}} </br >
{{/each}}
<div class="row">
{{input value=artist.groupname placeholder="Enter Artist name"}}
</div>
The issue appears when I set the controller "genres" property that I loaded in the route model().
App.EditRoute = Ember.Route.extend({
model: function(params) {
return Ember.RSVP.hash({
artist: this.store.find('artist',App.CurrentProfile.id),
genre: this.store.find('genre'),
});
},
setupController: function(controller, model) {
controller.set('artist', model.artist);
controller.set('genre', model.genre);
}
});
The artist data (artist.groupname) still works properly but the artist genre (related model artist.artist_genre) data is now empty in the template. Why would setting an additional controller property make the related model empty in the template? I still see the actual data in ember inspector.
Aucun commentaire:
Enregistrer un commentaire