title: Why is Rails not reloading my javascript files when I move between pages with an anchor?
body: <p><strong>UPDATE 2:</strong>
  I have temporarily fixed my problem by moving the javascript directly into my view file, but I would still like to know why Rails isn't reloading my javascript files when I move between pages using <code>&lt;a&gt;</code> tags.</p>
  
  <p><strong>UPDATE 1:</strong>
  I tried splitting the code into 2 views, one for the languages and one for the text changes.  When I link to the text page using an Anchor from the language page, even if I didn't do anything else on the language page beforehand, the contents of my home.js file doesn't run again.  Something is happening to destroy and create views without running the <code>document.ready</code> javascript again.</p>
  
  <p><strong>ORIGINAL:</strong>
  I am trying to build a Rails App that has multiple language support, but it's breaking the javascript farther down the page. In my view I have 2 anchors to switch between English and French, which when clicked refresh the page and all the text, language supported or not.  This is expected.</p>
  
  <p>After I click on either of these links however, the <code>keyup</code> javascript event i defined for a textarea farther down the page breaks entirely. I am not getting any errors in the Rails or javascript console, it just stops working.</p>
  
  <p>What is even more confusing is that while the code works before I click the anchors I am changing the text in the textarea from it's default value on page load. After I click the anchor the text changes back to the default page text as expected and my javascript breaks.  If I refresh the page with <code>F5</code> after it breaks, not only does the javascript work and the new language setting save, but the oldest value from the time the textarea javascript was still working reappears.</p>
  
  <p>Example sequence of events:</p>
  
  <ol>
  <li>initial page load, default text is "Try it out!/72y 17 0u7!"</li>
  <li>change text to "Try it", other textarea changes to "72y 17"</li>
  <li>change language, page reloads, default text is "Try it out!/72y 17 0u7!", javascript keyup event stops working but I change the first textarea to say "Hello World" instead</li>
  <li>refresh page with F5, javascript keyup event works again, textareas now say "Try it/72y 17"</li>
  </ol>
  
  <p>home.html</p>
  
  <pre><code>&lt;h3&gt;&lt;%= t('intro-title') %&gt;&lt;/h3&gt;
  &lt;p&gt;&lt;%= t('intro-paragraph') %&gt;&lt;/p&gt;
  &lt;a href="/?locale=en" type="button"&gt;English&lt;/a&gt;
  &lt;a href="/?locale=fr" type="button"&gt;Français&lt;/a&gt;
  
  &lt;textarea id="l33tify-in"&gt;Try it out!&lt;/textarea&gt;
  &lt;textarea id="l33tify-out" disabled="true"&gt;72y 17 0u7!&lt;/textarea&gt;
  </code></pre>
  
  <p>home.js</p>
  
  <pre><code>$( document ).ready(function() {
      $('#l33tify-in').keyup(function(){
          $.get('/l33tify_text', { 'l33tify_me' : $(this).val() }, function(data) {
              $('#l33tify-out').val(data['l33tified']);
          });
      });
  });
  </code></pre>
  
  <p>home_controller.rb</p>
  
  <pre><code>class HomeController &lt; ApplicationController
    before_action :set_locale
  
    def set_locale
      I18n.locale = params[:locale] || I18n.default_locale
    end
  
    def index
    end
  end
  </code></pre>