views:

329

answers:

2

When the user inadvertently double clicks on the table rows or anchors in the example below using Firefox, the Grow effect is stopped and the page becomes unusable. Any suggestions as to how to force FF to ignore the double clicks? I tried using Prototype's Stop.event and that didn't seem to help.

<table border=1>
<tr onclick="Effect.Grow('floater');">
 <td>Some Text</td>
 <td><a href="#" onclick = "Effect.Grow('floater');return false;">1</a></td>
 <td><a href="#" onclick = "Effect.Grow('floater');return false;">2</a></td>
</tr>

</table>

<div id = "floater" style="display:none;width:100%;height:100%;background-color:red">
<a href="#" onClick="Effect.Shrink('floater');return false;">close floater</a><div>
A: 

I haven't used script.aculo.us, so I cannot help with actual code, but it should be fairly simple to do the following. When onClick is fired, you should remove the event from the anchor before starting the shrinking. Once this effect is finished, you add the event back again to the anchor.

Zed
Thanks. I haven't found anything in Prototype to do that, though. There are plenty of ways to remove objects from the DOM,etc, but not events (at least that I can find).
Judson
+1  A: 

The problem is that script.aculo.us or Prototype handles the double click as a normal click, firing the Grow effect a second time and destroys the positioning of the element. With a simple patch (see below) of scriptaculous.js (1.8.2), I got it working, but it is more of a quick-and-dirty-fix for your specific problem:

760,763d759
<   if(element.growing){
<   return;
<   }
<   element.growing=true;
829d824
<                element.growing=false;
kanngard
Thanks so much for this answer. I'm having trouble though, and I suspect it's because I'm too ignorant to read these line numbers in the patch properly. Does "829d824" mean add at 829 or 824 or what? Again, I really appreciate it.
Judson
Look at Wikipedia for an expmanation of diff: http://en.wikipedia.org/wiki/Diff
kanngard