# Why won't this work - simple helper text?

**URL:** <https://www.ruby-forum.com/t/why-wont-this-work-simple-helper-text/57722>\
**Category:** Rails\
**Created:** [April 13, 2006, 12:49pm UTC](https://www.ruby-forum.com/t/why-wont-this-work-simple-helper-text/57722 "2006-04-13T12:49:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aftershock](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8e7dd6/32.png) [@aftershock](https://www.ruby-forum.com/u/aftershock)\
**Post date:** [April 13, 2006, 12:49pm UTC](https://www.ruby-forum.com/t/why-wont-this-work-simple-helper-text/57722/1 "2006-04-13T12:49:46Z")

</div>

Trying to print this out and it fails,

def cancel\_toggle(element)  
‘\<a href="#" onclick=“new Effect.toggle(”’ + element + ‘",“blind”,  
{duration: 0.4}); return false;" \>Add a New Client’  
end

When called in my view like this:  
\<%= cancel\_toggle “newClient” %\>

It gets written to the browser but does not work. When placed directly  
in the view it works. Firefox highlights the following in red (in source  
view):

newClient",“blind”

It must be something to do with my quotes but I cannot see it. Help  
please ???

---

<div class="post-metadata">

**Author:** ![aftershock](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8e7dd6/32.png) [@aftershock](https://www.ruby-forum.com/u/aftershock)\
**Post date:** [April 13, 2006, 1:06pm UTC](https://www.ruby-forum.com/t/why-wont-this-work-simple-helper-text/57722/2 "2006-04-13T13:06:39Z")

</div>

James W. wrote:

> It gets written to the browser but does not work. When placed directly  
> in the view it works. Firefox highlights the following in red (in source  
> view):
> 
> newClient",“blind”
> 
> It must be something to do with my quotes but I cannot see it. Help  
> please ???

‘Add a New Client’

should work. You had the same quote around the onclick attribute as  
around the javascript strings.

---

<div class="post-metadata">

**Author:** ![aftershock](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8e7dd6/32.png) [@aftershock](https://www.ruby-forum.com/u/aftershock)\
**Post date:** [April 13, 2006, 1:39pm UTC](https://www.ruby-forum.com/t/why-wont-this-work-simple-helper-text/57722/3 "2006-04-13T13:39:13Z")

</div>

Alex Y. wrote:

> James W. wrote:
> 
> > It gets written to the browser but does not work. When placed directly  
> > in the view it works. Firefox highlights the following in red (in source  
> > view):
> > 
> > newClient",“blind”
> > 
> > It must be something to do with my quotes but I cannot see it. Help  
> > please ???
> 
> ‘Add a New Client’
> 
> should work. You had the same quote around the onclick attribute as  
> around the javascript strings.

Thanks, I actually got it to work using this:

“\<a href=”#" class =“redLink” onclick=“new  
Effect.toggle(’#{element}’,‘blind’, {duration: 0.4}); return false;”

> cancel"

Your looks a little neater though. Thanks again.

---

<div class="post-metadata">

**Author:** ![aftershock](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8e7dd6/32.png) [@aftershock](https://www.ruby-forum.com/u/aftershock)\
**Post date:** [April 13, 2006, 3:00pm UTC](https://www.ruby-forum.com/t/why-wont-this-work-simple-helper-text/57722/4 "2006-04-13T15:00:41Z")

</div>

On 13-Apr-06, at 4:39 AM, James W. wrote:

> > > It must be something to do with my quotes but I cannot see it. Help
> 
> "\<a href="#" class ="redLink" onclick="new  
> Effect.toggle(‘#{element}’,‘blind’, {duration: 0.4}); return false;"
> 
> > cancel"
> 
> Your looks a little neater though. Thanks again.

Hi James,

If you’re willing to put up with extra noise at the beginning of your  
string you can get rid of the backslashes. This string is equivalent  
to yours:

%Q|cancel|

… and in case it gets mangled in the mail, it’s percent Q pipe at  
the start of the string and pipe at the end.

## Regards, Trevor

Trevor S.  
[http://somethinglearned.com](http://somethinglearned.com)
