I have a link that looks like this
index.html#/calendar/year/month
This is how I set up my routes:
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);
}
});
I can get to it by doing this:
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;
But I'd like to use the router instead.
I tried:
var router = this.get('target');
router.transitionTo('#calendar/'+year + '/' + nextMonth);
But I get this error:
Uncaught Error: assertion failed: The route #calendar/2013/5 was not found
I also tried:
var router = this.get('target');
router.transitionTo('calendar/'+year + '/' + nextMonth);
But this also gives me an error:
Uncaught Error: assertion failed: The route calendar/2013/5 was not found
Edit: displaying my routing above
router.transitionTo('#calendar/'+year + '/' + nextMonth);
you're missing a "/" after the "#". i don't know what else might be wrong, but i usually use something like eitherthis.transitionToRoute('example.name');
orApp.Router.router.transitionTo('example.name');
. – Jubaparams
argument in yourmodel
method in that route. – CanineRouter.map
and the declaration ofresource
androute
within it. I'll try to write something later today tho – Canine