In my Rails app I have this code
<%= form_for @experience, url: experience_path do |f| %>
<div class="experselect end-date">
<%= f.label :experience_end, class: "profile_label" %><br />
<%= f.date_select :experience_end, {start_year: 1945, discard_day: true, order: [ :day, :month, :year ]}, :html=> {class: 'date-select'} %>
</div>
<div class="form-checkbox current-item">
<%= f.check_box :experience_current, class: 'is_current', id: "checkbox_id" %>
I currently work here
</div>
<%= f.submit "Update experience" %>
And I have a link_to_add_fields method that add the same form as this I have also this script that disable the experience_end when the checkbox is checked and it works great.
function disableEndDate(thisObj) {
var targetedSelect = thisObj.closest(".form-checkbox").prev(".experselect").find("select");
if (thisObj.prop("checked")) {
targetedSelect.prop(
'disabled', true);
targetedSelect.css(
"background-color", "#D9D8DD");
} else {
targetedSelect.prop(
'disabled', false);
targetedSelect.css(
"background-color", "#FFFFFF");
}
}
$(document).ready(function(){
$("input[class='is_current']").click(function () {
disableEndDate($(this));
});
});
But actually my problem is when checkbox and submit the form and try to edit it again i find that the checkbox is checked and the select is disabled but the background of the select is not #D9D8DD as expected