render record data via ajax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="col-md-8"> | |
<div class="ibox-title"><h4>Employees</h4></div> | |
<div class="ibox-content"> | |
<table id="employee-table" class="table table-striped table-bordered table-hover"> | |
<thead> | |
<tr> | |
<th>Id</th> | |
<th>First Name</th> | |
<th>Last Name</th> | |
<th>Barcode</th> | |
</tr> | |
</thead> | |
<tbody> | |
<% @employees.each do |employee| %> | |
<tr class="empRow"> | |
<td><%= employee.id %></td> | |
<td><%= employee.first_name %></td> | |
<td><%= employee.last_name %></td> | |
<td><%= employee.barcode %></td> | |
</tr> | |
<% end %> | |
</tbody> | |
</table> | |
</div> | |
</div> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).on('click', '.empRow', function(){ | |
var empId = $(this).children('td').html(); //gets emp id | |
$.get('/employees.js?id=' + empId).success(function(){ | |
// $('#issuCard').css({'visibility':'visible'});// show card | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Card showing Information using Ajax --> | |
<div id="empCard"> | |
<div class="col-md-4"> | |
<div class="ibox-title"><h4><%= @employee.first_name %> <%= @employee.last_name %></h4></div> | |
<div class="ibox-content"> | |
<label for="">Employee ID: </label> <label><%= @employee.id %></label> <br> | |
<label for="">Employee Barcode: </label> <label><%= @employee.barcode %></label> <br> | |
<%= image_tag @employee.avatar.url(:thumb) %> | |
<hr> | |
<div class="row"> | |
<div class="col-md-6"> | |
<%= button_to 'View', employee_path(@employee.id), :class=>'btn btn-info btn-sm btn-block', :method => :get %> | |
</div> | |
<div class="col-md-6"> | |
<%= button_to 'Edit', edit_employee_path(@employee.id), :class=>'btn btn-default btn-sm btn-block', :method => :get %> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- EMPLOYEE INDEX --> | |
<div class="row"> | |
<div class="col-sm-8"> | |
<div class="pull-right"><%= link_to 'Add Employee', new_employee_path, class: "btn btn-w-m btn-primary" %></div> | |
</div> | |
</div><br> | |
<div class="row"> | |
<%= render 'employees' %> | |
<% if !!@employee %> | |
<%= render 'employee_card'%> | |
<% end %> | |
</div> | |
<br> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#empCard").html("<%= j(render(:partial => 'employee_card')) %>"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment