How do i use button_to_function

Hii all ,

      I am trying to create a button that, when clicked on, calls a

method in a controller . I am thinking that button_to_function is good
to use for that i made htnl viwe like

File Upload

Select File : <%= file_field 'upload', 'datafile' %>

<%= button_to_function "UploadFile","alert('Hello world!')"%> <%=button_to_function 'upload', remote_function({:action =>'uploadFile'}, :controller => 'UploadController') %>

but when i clicked on upload button nothing happen could anyone suggest
me how to this

Amit T. wrote in post #955655:

Hii all ,

      I am trying to create a button that, when clicked on, calls a

method in a controller . I am thinking that button_to_function is good
to use for that i made htnl viwe like

File Upload

Select File : <%= file_field 'upload', 'datafile' %>

<%= button_to_function "UploadFile","alert('Hello world!')"%> <%=button_to_function 'upload', remote_function({:action =>'uploadFile'}, :controller => 'UploadController') %>

but when i clicked on upload button nothing happen could anyone suggest
me how to this

Hi

You can use button_to_function with remote_function like

<%= button_to_function ‘Click me’, remote_function(:url=>{:action =>
‘uploadFile’, :controller => ‘UploadController’}} =>

remote_function is same options as link_to_remote and generates the an
ajax call.

Good Luck :wink:
-Ganesh K

Ganesh Kathare wrote in post #955659:

Amit T. wrote in post #955655:

Hii all ,

      I am trying to create a button that, when clicked on, calls a

method in a controller . I am thinking that button_to_function is good
to use for that i made htnl viwe like

File Upload

Thanks Ganesh i don’t but its working for me
Actully in my rails application i displayed a messagebox using win32api
but i am not to produce it at client site do you have any idea how
should i do that