I have checkboxes on my page, and the default value of all of them is true. However, the select_all checkbox became unchecked after a page refresh while the others remain checked.
<script>
var $checked = true;
$('#select_all').click(function() {
console.log('click select all button'+$checked)
$checked = !$checked
$(".activated").each(function(){
$(this).prop("checked", $checked)
});
});
</script>
<table cellspacing="10">
<thead>
<tr>
<%= check_box_tag 'select_all', 1, true%>
<%= label_tag :select_all, " Select All Doctors" %>
</tr>
</thead>
<tbody>
<tr>
<th>Send Email</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<% @doctors.each do |doctor| %>
<tr>
<td><%= check_box_tag 'activated[]', doctor.id, true, class: 'activated'%></td>
<td><%= doctor.first_name %></td>
<td><%= doctor.last_name %></td>
<td><%= doctor.email %></td>
</tr>
<% end %>
</tbody>
</table>
Aucun commentaire:
Enregistrer un commentaire