Button_to_function question

Hey everybody,
I am trying to create a button that, when clicked on, calls a method
in a controller then changes the image on the button without a page
load. I was thinking that button_to_function might be a good
contender for this but I don’t yet know how to make it talk to a
controller, and on success change the image of the button. Can anyone
help me out with this problem?

Thanks,
John

Jables wrote:

Hey everybody,
I am trying to create a button that, when clicked on, calls a method
in a controller then changes the image on the button without a page
load. I was thinking that button_to_function might be a good
contender for this but I don’t yet know how to make it talk to a
controller, and on success change the image of the button. Can anyone
help me out with this problem?

Thanks,
John

If you need to talk to controller, then it will load the page right?
Just put some helper method and call it in the button_to_function. Iam
not sure.

On Dec 4, 8:33 am, Ayyanar Aswathaman <rails-mailing-l…@andreas-
s.net> wrote:

Jables wrote:

Hey everybody,
I am trying to create a button that, when clicked on, calls a method
in a controller then changes the image on the button without a page
load. I was thinking that button_to_function might be a good
contender for this but I don’t yet know how to make it talk to a
controller, and on success change the image of the button. Can anyone
help me out with this problem?

button_to_function ‘Click me’, remote_function(:url=>{:action =>
‘foo’, :controller => ‘bar’}}

remote_function takes basically the same options as link_to_remote and
generates the javascript for an ajax call. You’ll want to read about
rjs for the final step of your problem

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs