-3

I have the navigation menu with <a>tags.

Now if I reload the page using browser refresh button, jQuery dom ready($(document).ready(function() {}) method is being invoked.

But if I click on navigation links, that time jQuery dom ready($(document).ready(function() {}) method is not invoked.

If it helps in any way, I'm using Ruby on Rails as a framework.

This is how my application.js looks like:

  //= require jquery
  //= require_tree
Kiran A B
  • 901
  • 1
  • 7
  • 13
  • 4
    Looks like you forgot to include your code in the question? – Jeremy Thille Jun 14 '16 at 13:06
  • There is no possible way for us to help unless you show us **your code** – Lexi Jun 14 '16 at 13:49
  • I could not include the code, as it was part of my office work. And due to privacy policy could not upload it. However I have solved the issue by adding onclick there. `onclick='window.location.replace("<%= hyperlink %>");'` I know it's not the best way to solve, however it worked for a time being. – Kiran A B Jan 06 '17 at 07:59

1 Answers1

0

I believe this is a result of Turbolinks. With turbolinks and most other single page frameworks the document.ready is called once. You should look at this SO question for a way to fix or work around it: Rails 4: how to use $(document).ready() with turbo-links.

Let me know if I was able to help.

Community
  • 1
  • 1
oreoluwa
  • 5,553
  • 2
  • 20
  • 27