I have checkboxes in my rails app. In filling forms, a checbox changes color to blue when it is checked. After the form is submitted and the User tries to edit/update the form, the checkbox 'checked color(blue)' does not show even though it is checked.
How can I make the 'checkbox active class' show even in the edit/update page. This is a sample of my checkbox code
<% Perk.all.each do |perk| %>
<input type="checkbox", class="hidden" value="<%= perk.id %>"
name="job[perk_ids][]" id="job_perk_ids_<%= perk.id %>"/>
<label class="category-choice" for="job_perk_ids_<%= perk.id %>">
<% end %>
This is my js file
$(document).ready(function(){
$(".category-choice").click(function(){
$(this).toggleClass("active");
});
});
In my css, i have
.category-choice {
background: #CFCFD3;
padding: 27px 15px 24px 10px;
&.active {
background: #51ADCF;
}
}
Aucun commentaire:
Enregistrer un commentaire