# Button\_to\_remote syntax

**URL:** <https://www.ruby-forum.com/t/button-to-remote-syntax/168850>\
**Category:** Rails\
**Created:** [May 26, 2009, 5:40pm UTC](https://www.ruby-forum.com/t/button-to-remote-syntax/168850 "2009-05-26T17:40:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stepheneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@stepheneb](https://www.ruby-forum.com/u/stepheneb)\
**Post date:** [May 26, 2009, 5:40pm UTC](https://www.ruby-forum.com/t/button-to-remote-syntax/168850/1 "2009-05-26T17:40:02Z")

</div>

Hey

I’m trying to make a button\_to\_remote that also has an associated style.

It works fine as a button\_to:  
\<%= button\_to “Paid”, has\_paid\_event\_booking\_path(booking,  
booking.event), :method =\> :post, :style =\>  
“background:url(/images/money\_add.png) left no-repeat; padding-left:  
15px” %\>

but then when I change it to button\_to\_remote:  
\<%= button\_to\_remote “Paid”, has\_paid\_event\_booking\_path(booking,  
booking.event), :method =\> :post, :before =\> “Effect.Fade('not\_paid\_” +  
booking.id.to\_s + “’)”,:style =\> “background:url(/images/money\_add.png)  
left no-repeat; padding-left: 15px” %\>

with the above code, the :before is ignored

So, I change the path to a :url hash:  
\<%= button\_to\_remote “Paid”, :url =\>  
has\_paid\_event\_booking\_path(booking, booking.event), :method =\> :post,  
:before =\> “Effect.Fade('not\_paid\_” + booking.id.to\_s + “’)”,:style =\>  
“background:url(/images/money\_add.png) left no-repeat; padding-left:  
15px” %\>

and then the :before works, but now the style is ignored!

How do I fix this?

Thanks in advance  
Steve Brown

---

<div class="post-metadata">

**Author:** ![stepheneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@stepheneb](https://www.ruby-forum.com/u/stepheneb)\
**Post date:** [May 26, 2009, 6:07pm UTC](https://www.ruby-forum.com/t/button-to-remote-syntax/168850/2 "2009-05-26T18:07:11Z")

</div>

On May 26, 4:40 pm, Stephen B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:  
above code, the :before is ignored

> So, I change the path to a :url hash:  
> \<%= button\_to\_remote “Paid”, :url =\>  
> has\_paid\_event\_booking\_path(booking, booking.event), :method =\> :post,  
> :before =\> “Effect.Fade('not\_paid\_” + booking.id.to\_s + “')”,:style =\>  
> “background:url(/images/money\_add.png) left no-repeat; padding-left:  
> 15px” %\>
> 
> and then the :before works, but now the style is ignored!

html options need to be in a second hash of options, ie  
button\_to\_remote ‘Foo’, {…}, {…}

Fred

---

<div class="post-metadata">

**Author:** ![stepheneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@stepheneb](https://www.ruby-forum.com/u/stepheneb)\
**Post date:** [May 26, 2009, 7:18pm UTC](https://www.ruby-forum.com/t/button-to-remote-syntax/168850/3 "2009-05-26T19:18:09Z")

</div>

Frederick C. wrote:

> html options need to be in a second hash of options, ie  
> button\_to\_remote ‘Foo’, {…}, {…}
> 
> Fred

Thanks. Works like a charm.
