I am trying to write a route that needs access to its parent model. I use this.modelFor() , but when I do this, the parent model is not fully loaded, so all its properties contain null .
This is a router with two dynamic segments:
MGames.Router.map(function () { this.resource('games', function () { this.resource ('game', {path: '/:game_id'}, function () { this.resource('board', {path: '/boards/:board_id'}); }); }); });
This is my GameRoute that works great:
MGames.GameRoute = Ember.Route.extend ({ model: function (params) { return MGames.Game.find(params.game_id); } });
And finally, this is a children's route that needs access to the Game model, and this is what I wrote. But no matter what I do, console.log() always prints null . If I check the game variable, the isLoad property isLoad always null:
MGames.BoardRoute = Ember.Route.extend ({ model: function (params) { var game = this.modelFor ('game'); console.log (game.get("id")); return MGames.Board.find(game.get("id"), params.board_id); } });
Am I doing something wrong, or (as I suspect) am I missing some Ember concept?
César García Tapia
source share