Turns out my full/ get
function was wrong…
I have my routes defined like this:
route('{resource}');
route('{resource}/{action}');
route('{resource}/{id}/{action}');
route.data = router.route;
route.ready();
And my “router” like this:
import DefineMap from 'can-define/map/';
import resources from '~/resources';
import alerts from '~/alerts';
import localisation from '~/localisation';
import security from '~/security';
import stache from 'can-stache';
var Route = DefineMap.extend({
resource: 'string',
action: 'string',
id: 'any',
full: {
get: function() {
return this.resource + !!this.id ? `/${this.id}` : !!this.action ? `/${this.action}` : '';
}
}
});
var Router = DefineMap.extend({
route: { Value: Route },
previousHash: 'string',
init: function () {
const self = this;
this.route.on('full', function () {
self.process.call(self);
});
},
process: function () {
// find the correct "componentName"
$('#application-content').html(stache('<' + componentName + '></' + componentName + '>')());
},
goto: function(href) {
window.location.hash = (href.indexOf('#!') === -1 ? '#!' : '') + href;
}
});
export default new Router();
However, if my url is, e.g., http://localhost:3969/development.html#!dashboard/2/1
and I change the 1
to anything else and press enter
the route change does not fire.
Any idea what I’m doing wrong?