0

我是rails的新手。我有一个按钮,单击该按钮会启动一个守护线程,我希望该按钮中的文本更改为“正在执行”,视图中的代码是

<td>
<% if data.vName == 'BuzzCity' or data.vName == 'neXva'%>
  <%= button_to "Start", { :action=> :execute_rake },  :remote => true  %>
<%end%>
</td>  

在控制器中是

def execute_rake
  vendor_name = 'neXva'#params[:vendorName]
  @async = ::AppMall::AsyncTask.new()
  if vendor_name == 'BuzzCity'

  elsif  vendor_name == 'neXva'

  else
   render :text => 'Unknown vendor'  
   return    
  end
 render :text => 'Executing'
end 
4

1 回答 1

1

只需添加此选项:disable_with

尝试这个,

<%= button_to "Start", { :action=> :execute_rake },  :remote => true, :disable_with => 'Executing...'  %>
于 2012-12-26T14:48:18.310 回答