Search code examples
htmlruby-on-railsrubyhrefturbolinks

href to same page div ID not working without refreshing page in ruby on rails


In rails views I have links which are linking to Div Ids of same page . When I click on it link the page refreshes and not work exactly.

It works only when I refresh the page then it moves to that div instead of refreshing the page.

Is it due to turbolinks?

e.g

<a href="#videos",class="active">
<div id="videos"></div>

This is not working unless I refresh the page.

How can I fix that issue?


Solution

  • Yes, it's due to turbolinks. Check out this section: https://github.com/turbolinks/turbolinks#disabling-turbolinks-on-specific-links

    or simply:

    <a href="#videos" data-turbolinks="false" class="active"></a>