Search code examples
htmlmeteorrouteshrefiron-router

Opening a link in new tab via context menu not working when using Router.go


I have a resources tag in the navbar.

On clicking it, user is navigated to that page (different URL). I did it using two different ways. Firstly, I used click event and used Router.go to navigate to that page.

HTML :

[li class="classic-menu-dropdown" id="resourcesNavBar"]
  [a href]Resources[/a]
[/li]

JS:

'click #resourcesNavBar': function(event, template) {
    Router.go('resources', {
        resource_id: "all"
    });
}

Then I used pathFor in the href tag to route to that page.

HTML

li class="classic-menu-dropdown" id="resourcesNavBar"             
  a href="{{pathFor 'resources' resource_id = 'all'}}">Resources[/a]            
/li

Both worked fine, but in the first method, on right-click, 'open link in new tab' doesn't show up whereas it works completely fine in the second method (open link in new tab).

Please enlighten as why does it happen.

Apologies if language isn't very clear.


Solution

  • Can you show us your HTLM to be sure? I guess this is because in the first method your link element doesn't have an href attribut, or is set to . So your browser thinks it is going nowhere.