0

我有一个包含 3 个单选按钮标签的远程表单,每个标签都会相应地更改数据库。这在 chrome 中工作得非常好,但是当我切换到 FF 时,收音机会被检查,除了 DB 之外的所有东西都没有改变。

这是我认为的形式。

<%= form_tag ("deal_status"), :remote => true, :class => "deals_status" do %>

    <%= hidden_field_tag 'deal_id', d.id.to_s %>

    <%= radio_button_tag( :state, "won"+d.id.to_s, d.state == "won", :class => "toggle-btn-left toggle-btn", :value =>"won") %>
    <%= label_tag  'state_won'+d.id.to_s, "won", :class=>"btn" %>   

    <%= radio_button_tag :state, "lost"+d.id.to_s, d.state == 'lost', :class => "toggle-btn-center toggle-btn",:value => "lost" %>
    <%= label_tag  'state_lost'+d.id.to_s, "lost",:class=>"btn" %>

    <%= radio_button_tag :state, "pending"+d.id.to_s, d.state == 'pending',:class => "toggle-btn-right toggle-btn", :value => "pending" %>
    <%= label_tag  'state_pending'+d.id.to_s, "pending",:class=>"btn" %>

<% end %>

这是提交的 js

$("body").on("change", "form :radio", function(){
    $(this).closest("form").submit();
});

这是控制器的操作:

  def deal_status

    deal_id = params[:deal_id]
    d = Deal.find_by_id(deal_id)
    d.state = params[:state]
    d.save

    @deal_id = deal_id
    @deal = d

      respond_to do |format|
      format.js 

    end
  end
4

0 回答 0