FIX_VEHICAL_MODAL_CLIENT_MODAL : RV
This commit is contained in:
parent
c127b088f6
commit
bbc3aa7e04
@ -1172,16 +1172,45 @@ $(document).ready(function(){
|
||||
// keyboard: false
|
||||
// })
|
||||
|
||||
isClientFormSubmitting = true;
|
||||
|
||||
$('#upload_enrollment_model').on('hide.bs.modal', function (e) {
|
||||
if (!isClientFormSubmitting) {
|
||||
// Ask for confirmation
|
||||
if (confirm("Are you sure you want to close? Unsaved changes will be lost.")) {
|
||||
// If confirmed, reset the form
|
||||
console.log('Attempting to hide #upload_enrollment_model modal');
|
||||
|
||||
let policy_type_id = $('#policy_type_id').val();
|
||||
console.log('policy_type_id:', policy_type_id);
|
||||
|
||||
// Only handle custom behavior for policy_type_id = 8
|
||||
if (policy_type_id == 8) {
|
||||
console.log('policy_type_id is 8 — custom handling begins.');
|
||||
|
||||
const shouldClose = confirm("Are you sure you want to close? Unsaved changes will be lost.");
|
||||
// const shouldClose = true; // Always true, can be changed to confirm() if needed
|
||||
console.log('User confirmation result:', shouldClose);
|
||||
|
||||
if (shouldClose) {
|
||||
console.log('User confirmed closing. Resetting #client_form.');
|
||||
|
||||
$('#client_form')[0].reset();
|
||||
console.log('#client_form reset successfully.');
|
||||
|
||||
$('#client_form').removeAttr('data-id');
|
||||
console.log('data-id attribute removed from #client_form.');
|
||||
|
||||
console.log('Opening #vehicle_modal.');
|
||||
const vehicleModal = new bootstrap.Modal(document.getElementById('vehicle_modal'));
|
||||
vehicleModal.show();
|
||||
|
||||
console.log('Setting form data for #vehicle_form from localStorage.');
|
||||
setFormDataFromLocalStorage("#vehicle_form", "vehicleFormData");
|
||||
|
||||
} else {
|
||||
// If not confirmed, prevent the modal from closing
|
||||
e.preventDefault();
|
||||
console.log('User cancelled closing. Preventing modal from hiding.');
|
||||
e.preventDefault(); // stops modal from closing
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log('policy_type_id is not 8 — proceeding with default modal behavior.');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user