Untitled
user_8884736
javascript
5 months ago
1.8 kB
4
Indexable
// Function to show modal with error message function showErrorModal(message, title) { // Create modal HTML var modalHtml = `<div class="modal fade" id="errorModal" tabindex="-1" role="dialog" aria-labelledby="errorModalLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header bg-dark text-light d-flex justify-content-between align-items-center"> <!-- Use d-flex, justify-content-between, and align-items-center for alignment --> <h5 class="modal-title text-danger mb-0" id="errorModalLabel">${title}</h5> <!-- Add mb-0 to remove extra margin --> <!-- <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> --> </div> <div class="modal-body"> <p>${message}</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> <!-- <button type="button" class="btn btn-primary">Save changes</button> --> </div> </div> </div> </div> `; // Append modal HTML to body $('body').append(modalHtml); // Show the modal $('#errorModal').modal('show'); // Remove modal from DOM after it's hidden $('#errorModal').on('hidden.bs.modal', function (e) { // console.log("masuk sini clear modal"); $('.modal').remove(); $(this).remove(); }); }
Editor is loading...
Leave a Comment