Forum: Ruby on Rails button_to_remote syntax

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8eee8667bf59e9812b7e8c399c78e46b?d=identicon&s=25 Stephen Brown (evolvedlight)
on 2009-05-26 17:40
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
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-05-26 18:07
(Received via mailing list)
On May 26, 4:40 pm, Stephen Brown <rails-mailing-l...@andreas-s.net>
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
8eee8667bf59e9812b7e8c399c78e46b?d=identicon&s=25 Stephen Brown (evolvedlight)
on 2009-05-26 19:18
Frederick Cheung wrote:

> html options need to be in a second hash of options, ie
> button_to_remote 'Foo', {...}, {...}
>
> Fred

Thanks. Works like a charm.
This topic is locked and can not be replied to.