单选按钮不会在Firefox中更改数据库但是它们在chrome中,为什么?

时间:2013-08-25 10:17:29

标签: javascript google-chrome firefox ruby-on-rails-3.2 cross-browser

我有一个包含3个单选按钮标签的远程表单,每个标签都会相应地更改DB。这在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

0 个答案:

没有答案