title: link_to and remote => true + jquery ajax:success
body: <p>I have a number of links on one page doing remote calls to update the content on the page. Everything works perfectly so I have decided to add a overlay to elements which have content loading so it gives the customer some visual reference that something is going on.</p>
  
  <p>So on each of the links where I want to show an overlay I add a class plus through the data attribute I pass in the div I want the overlay on. Here is some example code.</p>
  
  <pre><code>&lt;div id="content"&gt;Old Content&lt;/div&gt;
  &lt;%= link_to "Update Content", some_path, :class =&gt; 'ajax_trigger', :remote =&gt; true, 'data-target' =&gt; 'content' %&gt;
  </code></pre>
  
  <p>Ok so when clicked it runs off and loads the data with respond_to block format.js where I replace the content ie,</p>
  
  <pre><code>$("#content").html("&lt;%= escape_javascript(render(:partial =&gt; '/shared/content')) %&gt;")
  </code></pre>
  
  <p>And like I have said all works great.  Ok so I have a global bit of JS (coffee script) to do the overlay ie.</p>
  
  <pre><code>  $(".ajax_trigger").live("ajax:beforeSend", (evt, data, status, xhr) -&gt;
  
      # Get target div to add overlay
      target = $(this).data('target')
      $t = $("#"+target)
  
      # Update CSS for Overlay
      $("#overlay").css
        opacity: 0.7
        top: $t.offset().top
        left: $t.offset().left
        width: $t.outerWidth()
        height: $t.outerHeight()
  
      # Update Image for Overlay
      $("#img-load").css
        top: ($t.height() / 2)
        left: ($t.width() / 2)
  
      # Show Overlay
      $("#overlay").fadeIn()
  
    ).live("ajax:success", (evt, data, status, xhr) -&gt;
      $("#overlay").fadeOut()
    ).live "ajax:error", (evt, data, status, xhr) -&gt;
      alert "Failed!"
  </code></pre>
  
  <p>This works perfect for 2 items on the page but for one it shows the overlay but does not hide it. I am getting no errors as of course the ajax:alert with give me a warning.  The content loads in perfect on the overlay so again its all fine.</p>
  
  <p>I cant see how there is a difference and why it will not hide even though I got a good response and content replaced.</p>
  
  <p>Any suggestions how I can debug this?</p>