【问题标题】:Update attribute by Ajax Rails 3Ajax Rails 3 更新属性
【发布时间】:2012-11-14 14:02:07
【问题描述】:

我有一个带有两个单选按钮的表单,每个按钮都有自己的值,如下所示:

<%= form_for @product, url: ship_df_product_path(@product), remote: true do |f| %>

    <td><%= radio_button_tag 'ship', @product.ship_df %> Envío dentro DF - $<%= @product.envio_df %> </td>

    <td><%= radio_button_tag 'ship', @product.ship_int %> Envío interior del país- $<%= @product.envio_int %></td>

        <%= f.text_field :shipping, :class => "span2", :style => "display:" %>

<% end %>

问题是我需要更新@product 对象的“:shipping”属性,具体取决于点击了哪个。

我该怎么做?

非常感谢!

【问题讨论】:

    标签: ruby-on-rails ajax ruby-on-rails-3 forms radio-button


    【解决方案1】:

    尝试使用radio_button标签

    <td><%= f.radio_button 'ship', @product.ship_df %> Envío dentro DF - $<%= @product.envio_df %> </td>
    
    <td><%= f.radio_button 'ship', @product.ship_int %> Envío interior del país- $<%= @product.envio_int %></td>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多