0

So I've a navbar, and I've made my way to a sub dir in "Games" called "Cross" so, /games/cross. Now from that page, I'm trying to acess the Games page again from navbar but its showing /games/games... How do I fix this? I have the following...

Router.configure({
    layoutTemplate: 'layoutDefault'
});

Router.route('/', function(){
    this.render('main');
});

Router.route('/contact', {
    template: 'contact'
});

Router.route('/games', {
    template: 'games'
});

Router.route('/games/cross', {
    action: function() {
        if(Roles.userIsInRole(Meteor.user(), ['normal' , 'admins'])) {
            this.render('cross')
        }
        else
            this.render('denied')
    }
});
Farhan
  • 37
  • 1
  • 8

2 Answers2

4

Also you could use a helper function pathFor, Which returns the URL path component of any route.

syntax

{{pathFor 'path name'}}

To use pathFor you have to add a name property to your route.

Router.route('/contact', {
    name: 'content-view'
    template: 'contact'
});

<a href="{{pathFor 'content-view'}}">contact</a>

So if you ever decide to change the your route, you don't have to update all your links manually.

distalx
  • 342
  • 4
  • 13
0

If my understanding is correct, once you are in /games/cross page, you use your navbar to try to navigate back to the /games page, but your browser location bar now displays /games/games instead of just /games, and probably your router does not do anything? (or goes to whatever you have configured for route not found)

It might rather be an issue in the links of your navbar: have you tried prepending a slash / at the beginning of your href attribute value, so that the link is relative to your domain, not to the current page?

<a href="/games">Games</a>

Instead of:

<a href="games">Games</a>
ghybs
  • 47,565
  • 6
  • 74
  • 99