单击确认对话框OK后立即在rails 4 + jQuery + simple_form中隐藏按钮

问题描述 投票:0回答:1

在我的一种观点中,我有此代码:

 <%= simple_form_for upload,  :remote => true  do |f| %>
 <%= f.hidden_field :id, :value => upload.id %>
 <%= f.hidden_field :job, :value => "parse"%>
<%if (upload.status == 0)%>
    <%= f.button :submit, "Delete Entry:\n#{upload.sourcedata_file_name} from Database", :class=>"add_data_button" %>
<%elsif (upload.status == 1)%>
    <%= f.button :submit, "Add \n#{upload.sourcedata_file_name}\n to Database",:confirm=> "Start File parsing?", :class=> "add_data_button" %>
<%elsif (upload.status == 2)%>
    <%= "File has already been added to DB" %>
<%elsif (upload.status == 3)%>
    <%= "File is currently being added to DB" %>
<%else %>
    <%= "File has been removed from server" %>
<%end%>
 <% end %>

哪个呈现这样的内容:

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS80eFpHSi5wbmcifQ==” alt =“在此处输入图像说明”>“ >>

发生的情况是,如果用户在对话框上按OK,则该处理在服务器的后台开始,但该按钮仍然可见。我想做的是,如果用户单击“确定”,则立即禁用该按钮。

我知道我可以在JQuery中做到这一点。那就是我可以处理on_confirm按钮的OK单击事件,但是我无法在Internet上找到任何示例代码。

在我的一种观点中,我有以下代码:true | f | %> upload.id%>

jquery ruby-on-rails button view jquery-events
1个回答
0
投票

而不是以下内容:

© www.soinside.com 2019 - 2024. All rights reserved.