Files
railsgoat/app/views/admin/get_all_users.html.erb
T
Ken Johnson b3b1b0d01d Use jQuery modal API instead of Bootstrap 5 native API
Switch from bootstrap.Modal class to jQuery .modal('show') method.
Bootstrap 5 still supports the jQuery plugin API for backwards
compatibility, and this method handles initialization automatically.

This should fix the issue where modal.show() was called but the
modal wasn't appearing visually.

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

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

75 lines
2.1 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") {
console.log('Showing modal with jQuery');
// Use jQuery/Bootstrap method which handles initialization automatically
$('#editAcct').modal('show');
} else {
console.error('Failed to load modal content:', xhr.statusText);
}
});
};
function dataTablePagination(){
$('#data-table').dataTable({
"sPaginationType": "full_numbers"
});
};
$(document).ready(dataTablePagination());
</script>