Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link Routing issues #2662

Closed
silicahd opened this issue Jan 10, 2017 · 3 comments
Closed

Link Routing issues #2662

silicahd opened this issue Jan 10, 2017 · 3 comments

Comments

@silicahd
Copy link

Ok so far I have every single possibility. Here is the issue.

  1. The route I have is located in routes/admin/manageCoupons
  2. The views
    views/admin/layout.jade
    views/admin/coupons.jade
    views/admin/add_coupons.jade

In the layout i have a admin menu list

     ul.nav.nav-sidebar
                     li
                        a(href='../manageCoupons') Coupons
                    li
                        a(href='../manageCategories') Categories
                    li
                        a(href='../manageStores') Stores
                   

If I navigate to http://localhost:3000/admin/manageCoupons/addCoupon and try to press on the menu item the link will be http://localhost:3000/admin/manageCoupons

However if I go to http://localhost:3000/admin/manageCoupons the link will be http://localhost:3000/manageCoupons

Ok so that might be because I used ../ rather then ./ or admin/ or just /
However in all these cases the link will be ok in the main page but not ok when navigating to a sub route. you will likely get something like this.

  1. ./   will get   http://localhost:3000/admin/manageCoupons/manageCoupons
    
  2. /    will get   http://localhost:3000/manageCoupons
    
  3. ./admin/ will get http://localhost:3000/admin/manageCoupons/admin/manageCoupons
  4. just blank manageCoupons will get http://localhost:3000/admin/manageCoupons/manageCoupons

So no combination will fix the link issue. Any thought?
As explained when using ../manageCoupons will work from the sub route but it will brake when navigating to the manageCoupons view.

@jbsulli
Copy link
Contributor

jbsulli commented Jan 10, 2017

You just need a starting slash. If you start with a slash, the browser will look for that page relative to the root of the website (referred to as an absolute URL). If you don't, the browser will assume the path is relative to the document (referred to as a relative URL).

I think this is what you are trying to accomplish:

ul.nav.nav-sidebar
    li
        a(href='/admin/manageCoupons') Coupons
    li
        a(href='/admin/manageCategories') Categories
    li
        a(href='/admin/manageStores') Stores

@silicahd
Copy link
Author

wow what a moment. I tried every option but that.

Thank you so much.

@jbsulli
Copy link
Contributor

jbsulli commented Jan 10, 2017

You're welcome! I've definitely been there myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants