Ember router: jak używać przejścia do
Mam link, który wygląda tak
index.html#/calendar/year/month
W ten sposób skonfigurowałem moje trasy:
App.Router.map(function() {
this.resource('calendar', {path: 'calendar/:currentYear/:currentMonth'});
});
App.CalendarRoute = Ember.Route.extend({
model: function (params) {
var obj = {
weeks: calendar.getDaysInMonth(params.currentMonth, params.currentYear),
currentMonth: params.currentMonth,
currentYear: params.currentYear
};
return obj;
},
setUpController: function(controller, model) {
controller.set('content', model);
}
});
Mogę się do tego dostać, robiąc to:
var currentMonth = this.get('content.currentMonth');
var nextMonth = parseInt(currentMonth)+1;
var route = '#/calendar/'
var year = this.get('content.currentYear');
window.location.href= route + year + '/' + nextMonth;
Ale zamiast tego chciałbym użyć routera.
Próbowałem:
var router = this.get('target');
router.transitionTo('#calendar/'+year + '/' + nextMonth);
Ale dostaję ten błąd:
Nieprzechwycony błąd: asercja nie powiodła się: Nie znaleziono trasy # calendar / 2013/5
Próbowałem też:
var router = this.get('target');
router.transitionTo('calendar/'+year + '/' + nextMonth);
Ale to również daje mi błąd:
Nieprzechwycony błąd: asercja nie powiodła się: Nie znaleziono kalendarza trasy / 2013/5
Edytuj: wyświetlając mój routing powyżej