当我选中或取消选中复选框时,我正在尝试使用ID“ship-info-update”来获取我的div。我搜索了很多,但我似乎无法正常工作。
以下是我的_form.html.erb
的一部分 <%= field_set_tag "Shipping Info" do %>
<%= f.input :noship, :as => :boolean, label: 'No physical goods will be shipped', :id => "noship-checkbox" %>
<div id="ship-info-update">
<%= f.simple_fields_for :package do |p| %>
<% if @campaign.noship == true %>
<%= @campaign.weight = 0 %>
<% else %>
<%= p.input :weight, hint: 'Package weight of one unit in pounds (lbs)' %>
<% end %>
<% end %>
</div>
<% end %>