title: Why does JS only load whenever the page is first time loaded or refreshed?
body: <p>I have had this problem for a while whenever i builds Rails apps. Basically what happens is that every time you load the app and you have some sort of javascript code wether it's a tooltip or a datepicker it will only load it the first time you open the page or until you refresh the page</p>
  
  <p>So lets say you decide to visit the Services pages and you want to choose a date with the following code</p>
  
  <pre><code>$(document).ready -&gt;
     $("[data-behaviour~=datepicker]").datepicker(
     todayBtn: "linked", 
     todayHighlight: true, 
     startDate: "(Time.current, :format =&gt; :datepicker)"
     format: "yyyy/mm/dd"
  )
  </code></pre>
  
  <p>This code will load fine on first page load or until the page is refreshed, however if you go back and forth between pages the code for some reason won't load. As in the datepicker won't appear again until you refresh the page.</p>
  
  <p>This happens in both dev and production. Anyone know whats up and care to explain please? Am i doing something wrong?</p>
  
  <p>And no, the code doesn't go in application.js but rather in a seperate .js file and then gets called from application.js via the require tree i presume.</p>