Files
railsgoat/app/views/admin/get_all_users.html.erb
T
Ken Johnson dff2e150a2 Add more detailed modal debugging
- Log modal element to verify it exists
- Check for existing modal instance before creating new one
- Log each step of modal creation and show process

This helps identify why modal.show() isn't displaying the modal.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 22:12:59 +00:00

84 lines
2.3 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';
console.log('Loading modal content from:', link);
$("#editAcct .modal-content").load(link, function(response, status, xhr) {
console.log('Load status:', status);
if (status == "success") {
var modalElement = document.getElementById('editAcct');
console.log('Modal element:', modalElement);
// Get or create modal instance
var modal = bootstrap.Modal.getInstance(modalElement);
if (!modal) {
console.log('Creating new modal instance');
modal = new bootstrap.Modal(modalElement);
}
console.log('Showing modal');
modal.show();
} else {
console.error('Failed to load modal content:', xhr.statusText);
}
});
};
function dataTablePagination(){
$('#data-table').dataTable({
"sPaginationType": "full_numbers"
});
};
$(document).ready(dataTablePagination());
</script>