title: Create a custom jquery confirm dialog when clicking a link_to with method delete in rails
body: <p>how are you? I'm facing the following problem in rails 2.3.</p>
  
  <p>In a view I'm rendering an anchor with the link_to helper with method :delete, i.e.:</p>
  
  <pre><code>link_to "DELETE!", resource_path(@resource), :method =&gt; :delete
  </code></pre>
  
  <p>This works beautifully! But I want to span a confirm dialog before proceding with the destroy action. I could do this with the built-in confirm option:</p>
  
  <pre><code>link_to "DELETE!", resource_path(@resource), {:method =&gt; :delete, :confirm=&gt; "Are you sure?"
  </code></pre>
  
  <p>But I don't like this dialog style.</p>
  
  <p>I want a custom dialog generated by the <strong>jquery dialog</strong>. Thus I bind a click event on that link that span the confirm dialog I wanted.</p>
  
  <p>The big problem is that when the user clicks the link, the confirm dialog appears but the delete request is executed regardless the OK or CANCEL button is pressed. Inspecting the rendered link I remember that rails adds an onclick event over that link that generates the corresponding hidden form with _method: delete, etc, etc, etc.</p>
  
  <p>One solution is to make the AJAX delete request in the javascript function when the user clicks the OK button. However this approach will introduce some problems, I prefer not to do that.</p>
  
  <p>So what do you suggest in this situation? Is there a way to establish event order? I mean, capture first the event that spans the confirm dialog and depending on that unbind or cancel the future events?</p>
  
  <p>Thanks</p>