Skip to content

Instantly share code, notes, and snippets.

@EminenceHC
Last active December 27, 2015 18:59
Show Gist options
  • Save EminenceHC/7373752 to your computer and use it in GitHub Desktop.
Save EminenceHC/7373752 to your computer and use it in GitHub Desktop.
Javascript Problem
$(document).on('page:load', function(){
$("input:checkbox:not(:checked)").each(function() {
var column = "table ." + $(this).attr("name");
$(column).hide();
});
$("input:checkbox").click(function(){
var column = "table ." + $(this).attr("name");
$(column).toggle();
});
});
<% if current.loginable_type != 'Student' %>
<div class="span12">
<div style="float:right;">
<p><input type="checkbox" name="address" /> Address Info</p>
<p><input type="checkbox" name="phone" /> Phone Info</p>
</div>
<table id="report" class="table table-condensed table-bordered table-striped">
<tr>
<th>First</th>
<th>Middle</th>
<th>Last</th>
<th>UID</th>
<th>Email</th>
<th>Social</th>
<th>Sex</th>
<th class ="address">DOB</th>
<th class ="address">Address</th>
<th class ="address">City</th>
<th class ="address">State</th>
<th class ="address">Zip</th>
<th class ="phone">Home</th>
<th class ="phone">Work</th>
<th class ="phone">Mobile</th>
<th>Hire Date</th>
<th>Edit</th>
</tr>
</thead>
<% @counselors.each do |s| %>
<tbody>
<tr>
<td><%= s.first_name %></td>
<td><%= s.middle_name %></td>
<td><%= s.last_name %></td>
<td><%= s.id %></td>
<td><%= s.email %></td>
<td><%= s.social_security_no %></td>
<td><%= s.sex %></td>
<td><%= s.date_of_birth %></td>
<td class ="address"><%= s.street_address %></td>
<td class ="address"><%= s.city %></td>
<td class ="address"><%= s.state %></td>
<td class ="address"><%= s.postal_code %></td>
<td class ="phone"><%= s.home_phone %></td>
<td class ="phone"><%= s.work_phone %></td>
<td class ="phone"><%= s.mobile_phone %></td>
<td><%= s.loginable.hire_date %></td>
<td><%= link_to "Edit", edit_counselor_path(@counselor, id: s.loginable.id) %></td>
</tr>
</tbody>
<% end %>
</table>
</div>
<% else %>
<h2>You are not authorized to view this page.</h2>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment