title: An element in $(document).ready is undefined in a certain situation
body: <p>This question comes from </p>
  
  <p>Actually, I was able to find a clue and this is what I found. I have a js file:</p>
  
  <pre><code>$(document).ready(function() {
    var myIdElement = $("#some_id");
  
    //............
    $.ajax({
      url: getFullUrl(myIdElement.val())
    })
    //..........
  </code></pre>
  
  <p>So when I come to this page from the another page by a link (html link) then <code>myIdElement</code> is <code>undefined</code>. However, when I reload the page it starts having a proper value. I use turbolinks.</p>
  
  <p>How do I get it to work in all situations?</p>