Possibly related: Nested Models in Backbone.js, how to approach
Code snippet:
define([
'jquery',
'backbone',
], function($, Backbone){
var GenreModel = Backbone.Model.extend({
defaults: {
currentGenre: null,
availableGenres: []
},
initialize: function() {}
});
var MusicModel = Backbone.Model.extend({
defaults: {
genre: new GenreModel()
},
initialize: function() {}
});
// Return the model for the module
return MusicModel;
});
Is the above practice acceptable? I only have one level of nested models MusicModel.get('genre')
. The reason I am doing this is that while I want to listen to the changes in the genre model, I don't want to create another view for genre
because it's too small. I'd appreciate any suggestions!