Search code examples
backbone.jshyperlinkchaplinjs

redirect to page and anchor using ChaplinJs


I have a page /hello where i have a link:

<a href="{{#url 'goodbye' }}{{/url}}">

that will redirect to /goodbye. But i want it to use an anchor too, something like /goodbye#message

I have tried doing:

<a href="{{#url 'goodbye' }}{{/url}}#message">

but when I click on it, it will redirect the page to /goodbye. It seems like Chaplin is deleting the anchor.

EDIT: For the templates I'm using handlebars (with the chapling boilerplate), the {{#url}} helper generates correctly the link ( cf view-helper.js ). In the rendered page i see:

<a href="/goodbye#message">

but when i click on it, it just redirects me to /goodbye

Any idea?


Solution

  • Found a solution, I needed to stop the routing on the link. I just added the class noscript on the tag

    <a href="{{#url 'goodbye' }}{{/url}}#message" class="noscript">
    

    I couln't find a different way to do it. Hope this helps someone else

    cf : skipRounting on Chaplin.Layout