title: Rails remote call, response reloads page and jump to anchor
body: <p>I have a <code>destroy</code> method where:</p>
  
  <ul>
  <li>It is called via <code>link_to</code> and <code>remote: true</code></li>
  <li>After deletion, I want to tell browser to redirect to a page</li>
  <li>And jump the user down to a specific anchor <strong>(this bit isn't working)</strong></li>
  </ul>
  
  <p>Code looks like:</p>
  
  <pre><code>def destroy
    # code to delete objects
    respond_to do |format|
      format.js { render js: %(window.location.href = "/docs/#{@doc.id}") }
    end
  end
  </code></pre>
  
  <p>This works: directing browser to documents page (e.g. <code>/docs/42</code>).</p>
  
  <p>But I really want to direct user to documents page <strong>and</strong> jump down to anchor on the page. </p>
  
  <p>I started with the approach below (i.e. create something like <code>/docs/42#section_2</code>) but this doesn't reload page. </p>
  
  <pre><code>def destroy
    # code to delete objects
    respond_to do |format|
      format.js { render js: %(window.location.href = "/docs/#{@doc.id}#section_#{@doc.section.id}") }
    end
  end
  </code></pre>
  
  <p>Using Chrome dev tools, the javascript seems to be coming to browser okay. Have also tried variously with:</p>
  
  <ul>
  <li><code>window.location</code></li>
  <li><code>window.location.replace</code></li>
  </ul>
  
  <p>What am I missing? </p>
  
  <p><strong>UPDATE</strong>: additional info (apologies for not including earlier) to clarify.</p>
  
  <p>Say we are on page <code>/docs/42</code>:</p>
  
  <ul>
  <li>The <code>destroy</code> method is triggered from a button in Bootstrap modal</li>
  <li>Clicking on button should send <code>remote</code> ajax call to invoke <code>destroy</code></li>
  <li><code>destroy</code> executes</li>
  <li>Javascript is returned to browser, causing redirect to URL (complete page refresh) to <code>/docs/42</code> now with refreshed content</li>
  <li>End goal is to redirect to <code>/docs/42#section42</code> (jump down page to anchor)</li>
  </ul>
  
  <p>So what's observed so far:</p>
  
  <ul>
  <li>URL of form <code>/docs/42</code> yields correct behavior</li>
  <li>URL of form <code>/docs/42#section_21</code> yields unintended behavior</li>
  </ul>
  
  <p>Unintended behavior observed:</p>
  
  <ul>
  <li>Page does not refresh (so unrefreshed content remains)</li>
  <li>Underneath modal, I can see page jump to anchor (<code>#section_21</code>)</li>
  <li>Modal stays on page</li>
  </ul>