1
:現在のボックスにチェックするときチェックすると、私はこれらのコードを持って無効フォーム
<div class="nested-fields">
<div class="row">
<div class="col-sm-4">
<div class="form-group">
<%= f.input :start_work, as: :date, start_year: Date.today.year - 20,
end_year: Date.today.year, ignore_day: true,
order: [:month, :year],
input_html: { class: 'form-control' },
label: 'Start work period' %>
</div>
<div class="form-group">
<%= f.input :is_current, label: 'Currently work here', input_html: { class: 'current' } %>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<%= f.input :end_work, input_html: {class: 'end_work'}, as: :date, start_year: Date.today.year - 20,
end_year: Date.today.year, ignore_day: true,
order: [:month, :year],
input_html: { class: 'form-control' },
label: 'End work period' %>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function() {
// experience current work
$(".current").each(function() {
$(this).click(function() {
var isCurrent = $(this).prop("checked");
if (isCurrent == true) {
$(this).closest('.form-group').next('.form-group').find('.end_work').prop("disabled", "disabled");
}
else {
$(this).closest('.form-group').next('.form-group').find('.end_work').prop("disabled", false);
}
});
});
});
</script>
はしかし、私は私のend_work入力を無効にすることはできません。私は、Javascriptでターゲットクラスや何かを逃したと思う。どんな助けも素晴らしいでしょう!