【发布时间】:2020-01-14 21:02:41
【问题描述】:
这就是我正在尝试做的事情。在我的“创建作业”中,我希望仅在 assignment_type 的下拉菜单中选择了“视频”时才显示“链接”问题。
<%= render 'shared/errors', obj: @assignment %>
<%= form_for(@assignment, :html => {class: "form-horizontal", role: "form"}) do |f| %>
<div class="form-group">
<div class = "xtrapadding">
<%=f.label "Select Unit(s) for Assignment"%>
<%= f.collection_select(:unit_ids, Unit.all, :id, :name, {placeholder: "Units"}, {multiple: true} )%>
</div>
<div class="form-group">
<%= f.label :assignment_type %>
<%= f.select :assignment_type, options_for_select(Assignment.options, params[:type]), {}, required: true, class: 'form-control' %>
</div>
<div>
<%= f.text_field :name, class:"form-control", placeholder: "Title of Assignment", autofocus: true %>
</div>
<div class="field">
<b><%= f.label :description %></b>
<%= f.rich_text_area :description %>
</div>
<div>
<%= f.text_field :duedate, class: "datepicker", placeholder: "Due Date"%>
</div>
<div>
<%= f.text_field :link, class:"form-control", placeholder: "Insert video link", autofocus: true %>
</div>
<div class="form-group" id="submitbutton">
<div align = "center">
<%= f.submit class: "btn waves-effect waves-light" %>
</div>
</div>
</div>
<%end%>
这是我想根据链接显示或隐藏的最后一个问题。我希望它默认为隐藏,但在使用特定值选择下拉列表时可见。我相当确定我需要使用 Ajax,但除此之外我不太确定从哪里开始。谢谢!顺便说一句,我正在使用 Webpacker 和 Rails 6。
【问题讨论】:
标签: jquery ruby-on-rails ajax ruby-on-rails-6