Files
railsgoat/app/views/admin/get_all_users.html.erb
T
Ken Johnson 779bece728 Prevent default link navigation in admin user edit button
Add 'return false;' to onClick handler to prevent the # href
from causing page navigation/redirect to dashboard.

This fixes the issue where clicking Edit would redirect to
/admin/1/dashboard# instead of opening the modal.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 21:28:55 +00:00

66 lines
1.8 KiB
Plaintext
Executable File

<div id="dt_example" class="example_alt_pagination">
<table class="table table-striped table-hover table-bordered pull-left" id="data-table">
<thead>
<tr>
<th>
Name
</th>
<th>
Email
</th>
<th>
Admin User
</th>
<th>
Action
</th>
</tr>
</thead>
<tbody>
<% @users.each do |u|%>
<tr>
<td style="word-wrap:break-word;">
<%= "#{u.first_name} #{u.last_name}"%>
</td>
<td>
<%= u.email%>
</td>
<td>
<%= u.admin ? %{<span class="fs1" aria-label="check" data-icon="&#xe0fe;"}.html_safe : nil %>
</td>
<td>
<%= link_to "Edit", "#", {:onClick => "javascript:openEditModal(#{u.id}); return false;", :role => "button", :style => "width:70px", :class => "btn btn-inverse"}%>
</td>
</tr>
<% end %>
</tbody>
</table>
<div id="editAcct" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<!-- Content will be loaded here dynamically -->
</div>
</div>
</div>
<div class="clearfix">
</div>
</div>
</div>
<script type="text/javascript">
function openEditModal(id){
var link = '/admin/'+ id +'/get_user';
$("#editAcct .modal-content").load(link);
var modal = new bootstrap.Modal(document.getElementById('editAcct'));
modal.show();
};
function dataTablePagination(){
$('#data-table').dataTable({
"sPaginationType": "full_numbers"
});
};
$(document).ready(dataTablePagination());
</script>