# Link\_to\_function

**URL:** <https://www.ruby-forum.com/t/link-to-function/101858>\
**Category:** Rails\
**Created:** [August 8, 2006, 11:24am UTC](https://www.ruby-forum.com/t/link-to-function/101858 "2006-08-08T11:24:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lamaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/76d3ee/32.png) [@lamaa](https://www.ruby-forum.com/u/lamaa)\
**Post date:** [August 8, 2006, 11:24am UTC](https://www.ruby-forum.com/t/link-to-function/101858/1 "2006-08-08T11:24:37Z")

</div>

Hello

I wonder why this happens:

this:

\<%= link\_to\_function image\_tag(“chart\_bar.png”), :onclick=\>“new  
Effect.toggle(‘bar-project#{project.id}’)” %\>

outputs this:

a href="#" onclick=“onclicknew Effect.toggle(‘bar-project188’); return  
false;”\> ![Chart_bar](https://test.ruby-forum.com/images/chart_bar.png?1142196636)

the link\_to\_funtions returns twice onclick hence it will not work.  
please help

---

<div class="post-metadata">

**Author:** ![lamaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/76d3ee/32.png) [@lamaa](https://www.ruby-forum.com/u/lamaa)\
**Post date:** [August 8, 2006, 11:34am UTC](https://www.ruby-forum.com/t/link-to-function/101858/2 "2006-08-08T11:34:21Z")

</div>

> \<%= link\_to\_function image\_tag(“chart\_bar.png”), :onclick=\>“new  
> Effect.toggle(‘bar-project#{project.id}’)” %\>

I think you want this instead:

\<%= link\_to\_function image\_tag(“chart\_bar.png”), “new  
Effect.toggle(‘bar-project#{project.id}’)” %\>
