Remove Test Code that end up not using
This commit is contained in:
@@ -1,63 +0,0 @@
|
|||||||
// Generic Ajax Modal Load Script
|
|
||||||
//
|
|
||||||
/*Trigger Button using data-ajax attributes -->
|
|
||||||
<button type="button"
|
|
||||||
class="btn btn-primary ajax-trigger"
|
|
||||||
data-ajax="ajax_edit_contact.php"
|
|
||||||
data-ajax-id="123">
|
|
||||||
Edit Contact
|
|
||||||
</button>
|
|
||||||
*/
|
|
||||||
$(document).on('click', '.ajax-trigger', function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
// Get the URL and ID from the element's data attributes
|
|
||||||
var $trigger = $(this);
|
|
||||||
var ajaxUrl = $trigger.data('ajax-url');
|
|
||||||
var ajaxId = $trigger.data('ajax-id');
|
|
||||||
|
|
||||||
// Make the AJAX call to fetch modal content
|
|
||||||
$.ajax({
|
|
||||||
url: ajaxUrl,
|
|
||||||
method: 'GET',
|
|
||||||
data: { id: ajaxId },
|
|
||||||
dataType: 'json',
|
|
||||||
success: function (response) {
|
|
||||||
if (response.error) {
|
|
||||||
alert(response.error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a unique modal ID (you can enhance this as needed)
|
|
||||||
var modalId = 'dynamicAjaxModal';
|
|
||||||
|
|
||||||
// Build the modal HTML using the returned title and content
|
|
||||||
var modalHtml =
|
|
||||||
'<div class="modal fade" id="' + modalId + '" tabindex="-1" role="dialog" aria-labelledby="' + modalId + 'Label" aria-hidden="true">' +
|
|
||||||
' <div class="modal-dialog" role="document">' +
|
|
||||||
' <div class="modal-content bg-dark">' +
|
|
||||||
' <div class="modal-header">' +
|
|
||||||
' <h5 class="modal-title" id="' + modalId + 'Label">' + response.title + '</h5>' +
|
|
||||||
' <button type="button" class="close text-white" data-dismiss="modal" aria-label="Close">' +
|
|
||||||
' <span aria-hidden="true">×</span>' +
|
|
||||||
' </button>' +
|
|
||||||
' </div>' +
|
|
||||||
' <div class="modal-body bg-white">' + response.content + '</div>' +
|
|
||||||
' </div>' +
|
|
||||||
' </div>' +
|
|
||||||
'</div>';
|
|
||||||
|
|
||||||
// Append the modal to the body and show it
|
|
||||||
$('body').append(modalHtml);
|
|
||||||
$('#' + modalId).modal('show');
|
|
||||||
|
|
||||||
// Remove the modal from the DOM once it's hidden
|
|
||||||
$('#' + modalId).on('hidden.bs.modal', function () {
|
|
||||||
$(this).remove();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
error: function () {
|
|
||||||
alert('Error loading modal content.');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
$(document).on('click', '.edit-contact-btn', function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
var contactId = $(this).data('contact-id');
|
|
||||||
$('#editContactContent').html('Loading...'); // optional loading text
|
|
||||||
$.get('ajax_edit_contact.php', { contact_id: contactId }, function(response) {
|
|
||||||
$('#editContactContent').html(response);
|
|
||||||
$('#editContactModal').modal('show');
|
|
||||||
}).fail(function() {
|
|
||||||
alert('Error loading contact details.');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<!-- Static Modal Container -->
|
|
||||||
<div class="modal fade" id="editContactModal" tabindex="-1" role="dialog" aria-labelledby="editContactModalLabel" aria-hidden="true">
|
|
||||||
<div class="modal-dialog" role="document">
|
|
||||||
<div class="modal-content">
|
|
||||||
<!-- Modal Header with Dynamic Title -->
|
|
||||||
<div class="modal-header">
|
|
||||||
<h5 class="modal-title" id="editContactModalLabel">Edit Contact</h5>
|
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
||||||
<span aria-hidden="true">×</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<!-- Modal Body: Content will be loaded via AJAX -->
|
|
||||||
<div class="modal-body" id="editContactModalContent">
|
|
||||||
<!-- Loading message shown until AJAX returns -->
|
|
||||||
<p>Loading...</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
Reference in New Issue
Block a user