# Link\_to ...onclick + ondoubleclick

**URL:** <https://www.ruby-forum.com/t/link-to-onclick-ondoubleclick/172605>\
**Category:** Rails\
**Created:** [July 24, 2009, 12:13am UTC](https://www.ruby-forum.com/t/link-to-onclick-ondoubleclick/172605 "2009-07-24T00:13:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [July 24, 2009, 12:13am UTC](https://www.ruby-forum.com/t/link-to-onclick-ondoubleclick/172605/1 "2009-07-24T00:13:41Z")

</div>

I wrote a test link :

\<%= link\_to(“test dbl click”, root\_url, :ondblclick =\> “alert(‘Double  
Clicked’);”) %\>

the double click event is captured (alert displayed) but at the same  
time the home page is also displayed , is there a way to wait for the  
ok on the panel before executing the link?

---

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [July 24, 2009, 8:16pm UTC](https://www.ruby-forum.com/t/link-to-onclick-ondoubleclick/172605/2 "2009-07-24T20:16:02Z")

</div>

> \<%= link\_to(“test dbl click”, root\_url, :ondblclick =\> “alert(‘Double  
> Clicked’);”) %\>
> 
> the double click event is captured (alert displayed) but at the same  
> time the home page is also displayed , is there a way to wait for the  
> ok on the panel before executing the link?

\<%= link\_to(“test dbl click”, root\_url, :ondblclick =\> “return  
confirm(‘Double  
Clicked’);”) %\>

Why the double click? If you don’t need that you can get away with:

\<%= link\_to(“test confirmed click”, root\_url, :confirm =\> “Press OK to  
go to root url”) %\>

-philip
