title: Javascript with jQuery: Click and double click on same element, different effect, one disables the other
body: <p>I have an interesting situation - I have a table row which, currently, shows it's hidden counterpart when I click the "Expand" button. The original (unhidden) row which contains the expand button also has some content in a certain cell which, when clicked, becomes editable. I would like to be rid of the expand button, and enable expanding of the row via doubleclick anywhere in the row itself, including the field that turns editable when you click it. You can smell the trouble here already.</p>
  
  <p>When I double click a row, two click events are fired first, before the dblclick occurs. This means if I double click the field, it will turn into an editable one, and the row will expand. I would like to prevent this. I want the doubleclick to prevent the firing of the single click, and the single click to perform as usual.</p>
  
  <p>Using event.stopPropagation() clearly won't work since they're two different events.</p>
  
  <p>Any ideas?</p>
  
  <p>Edit (some semi-pseudo code):</p>
  
  <p>Original version:</p>
  
  <pre><code>&lt;table&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href="javascript:$('#row_to_expand').toggle();" title="Expand the hidden row"&gt;Expand Row&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Some kind of random data&lt;/td&gt;
              &lt;td&gt;&lt;?= $editable_cell_which_turns_into_an_input_field_on_single_click[0]-&gt;value("First editable value") ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?= $editable_cell_which_turns_into_an_input_field_on_single_click[1]-&gt;value("Second editable value") ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?= $editable_cell_which_turns_into_an_input_field_on_single_click[2]-&gt;value("Third editable value") ?&gt;&lt;/td&gt;
              &lt;!-- ... --&gt;
              &lt;td&gt;&lt;?= $editable_cell_which_turns_into_an_input_field_on_single_click[n]-&gt;value("Nth editable value") ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr style="display: none" id="row_to_expand"&gt;
              &lt;td colspan="n"&gt;Some hidden data&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Desired version:</p>
  
  <pre><code>&lt;table&gt;
      &lt;tbody&gt;
          &lt;tr ondblclick="$('#row_to_expand').toggle()"&gt;
              &lt;td&gt;Some kind of random data&lt;/td&gt;
              &lt;td&gt;&lt;?= $editable_cell_which_turns_into_an_input_field_on_single_click[0]-&gt;value("First editable value") ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?= $editable_cell_which_turns_into_an_input_field_on_single_click[1]-&gt;value("Second editable value") ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?= $editable_cell_which_turns_into_an_input_field_on_single_click[2]-&gt;value("Third editable value") ?&gt;&lt;/td&gt;
              &lt;!-- ... --&gt;
              &lt;td&gt;&lt;?= $editable_cell_which_turns_into_an_input_field_on_single_click[n]-&gt;value("Nth editable value") ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr style="display: none" id="row_to_expand"&gt;
              &lt;td colspan="n"&gt;Some hidden data&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Cheers</p>