在我的 Rails 应用程序中,我有这两个link_to
显然都做了一些事情。当我
<% if Excont.where(:user_id=> current_user,:movie_id => @movie.id,:actionall => '2').includes(:user).all.count == 0%>
<tr style="border-top: none; ">
<td>
<%= link_to('Mark as action', {:controller => :excont, :action => 'thisisanaction', :id=> @movie.id, :actionall=>'2'}, :method => :post, :remote => true, :disable_with => 'Updating...') %>
</td>
</tr>
<% else %>
<tr style="border-top: none;">
<td>
<%= link_to('Unmark as action', {:controller => :excont, :action => 'removethisisanaction', :id=> @movie.id, :actionall=>'2'}, :method => :post, :remote => true, :disable_with => 'Updating...') %>
</td>
</tr>
<% end %>
当我单击第一个link_to
(thisisanaction)时,它运行Updating...
然后返回到Mark as action
,如果我重新加载它会变为Unmark as action
.
我要问的是如何从
Mark as action
-> Updating...
->Unmark as action
进而
Unmark as action
--> Updating...
->Mark as action
无需重新加载页面。我的 JS 代码会是什么样子