updated notes with services and updated sample texts on views
This commit is contained in:
@@ -5,7 +5,7 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
console.log('Client modals AJAX script loaded with SweetAlert.');
|
||||
|
||||
|
||||
// Generic AJAX handler for standard forms (Shortcodes & Payments)
|
||||
$(document).on('submit', '#shortcodeForm, #paymentForm, #noteForm', function(e) {
|
||||
@@ -122,7 +122,7 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||
// Only fetch if options haven't been loaded yet
|
||||
if ($select.children('option').length === 0) {
|
||||
$.ajax({
|
||||
url: base_url + '/api/services', // Update route if needed
|
||||
url: base_url + '/api/services',
|
||||
type: 'GET',
|
||||
success: function(data) {
|
||||
$select.empty();
|
||||
@@ -151,6 +151,40 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||
}
|
||||
});
|
||||
|
||||
// Initialize Select2 for Note Services when modal opens
|
||||
$('#addNoteModal').on('shown.bs.modal', function () {
|
||||
let $select = $('#noteServicesSelect');
|
||||
|
||||
if ($select.children('option').length === 0) {
|
||||
$.ajax({
|
||||
url: base_url + '/api/services',
|
||||
type: 'GET',
|
||||
success: function(data) {
|
||||
$select.empty();
|
||||
data.forEach(function(service) {
|
||||
$select.append(new Option(service.name, service.id, false, false));
|
||||
});
|
||||
|
||||
$select.select2({
|
||||
theme: 'bootstrap-5',
|
||||
dropdownParent: $('#addNoteModal'),
|
||||
placeholder: 'Search and select services...'
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$select.select2({
|
||||
theme: 'bootstrap-5',
|
||||
dropdownParent: $('#addNoteModal'),
|
||||
placeholder: 'Search and select services...'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Clear Select2 values when modal is closed
|
||||
$('#addNoteModal').on('hidden.bs.modal', function () {
|
||||
$('#noteServicesSelect').val(null).trigger('change');
|
||||
});
|
||||
// Clear Select2 values when modal is closed
|
||||
$('#addPaymentModal').on('hidden.bs.modal', function () {
|
||||
$('#paymentServicesSelect').val(null).trigger('change');
|
||||
|
||||
Reference in New Issue
Block a user