1

I have a button on my Ruby on Rails app which calls a function on my controller.

When I click on the button I call a function.

So I want do disable this button after clicking on it, then able it again after my function was done.

How can I do it?

below my view code

<div style="float: left; width: auto; padding-right: 1%">
    <%= button_to_function l(:gerar_build_project), remote_function(:action => 'exec_client', :controller => 'repositories') %>
</div>
kamusett
  • 1,403
  • 1
  • 12
  • 22

2 Answers2

0

You can disable any button with :disable_with attribute. Try this :

<div style="float: left; width: auto; padding-right: 1%">
    <%= button_to_function l(:gerar_build_project), remote_function(:action => 'exec_client', :controller => 'repositories'), :disable_with => "Submitting...." %>
</div>

Hope it will help. Thanks

Rails Guy
  • 3,836
  • 1
  • 20
  • 18
0
  1. use jquery-rails gem
  2. include jquery, jquery_ujs in your page
  3. for button_to_function method use 'data-disable-with' => 'Submitting'