From: fomichev Date: Wed, 22 Apr 2026 06:48:20 +0000 (+0300) Subject: fix plantation X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=d45ea21354ac25e5d505c99ecdb666c43bc6aea4;p=erp24_rep%2Fyii-erp24%2F.git fix plantation --- diff --git a/erp24/web/js/supplier/index.js b/erp24/web/js/supplier/index.js index 55be3fa5..ff8f6e5d 100644 --- a/erp24/web/js/supplier/index.js +++ b/erp24/web/js/supplier/index.js @@ -10,22 +10,22 @@ console.log('[supplier] #supplier-modal найден:', !!modalEl); if (!modalEl) { - console.error('[supplier] КРИТИЧНО: #supplier-modal не найден в DOM — modal не создан'); return; } - // Проверяем, есть ли уже Bootstrap-инстанс на элементе - var existingInstance = bootstrap.Modal.getInstance(modalEl); - console.log('[supplier] существующий bootstrap.Modal.getInstance:', existingInstance); - - var supplierModal = new bootstrap.Modal(modalEl); - console.log('[supplier] новый bootstrap.Modal создан:', supplierModal); - var editingId = null; var shouldReload = false; + var _bsModal = null; var loaderHtml = '
'; + function getModal() { + if (!_bsModal) { + _bsModal = new bootstrap.Modal(modalEl); + } + return _bsModal; + } + modalEl.addEventListener('hidden.bs.modal', function () { if (shouldReload) { shouldReload = false; @@ -50,9 +50,8 @@ editingId = null; $('#supplier-modal-title').text('Добавить поставщика'); $('#supplier-modal-body').html(loaderHtml); - console.log('[supplier] вызываем supplierModal.show()'); - supplierModal.show(); - console.log('[supplier] supplierModal.show() вызван, загружаем форму:', urls.createForm); + getModal().show(); + console.log('[supplier] форму загружаем:', urls.createForm); $.get(urls.createForm, function (html) { console.log('[supplier] createForm ответ получен, длина HTML:', html.length); $('#supplier-modal-body').html(html); @@ -73,7 +72,7 @@ editingId = $btn.data('id'); $('#supplier-modal-title').text('Редактировать поставщика'); $('#supplier-modal-body').html(loaderHtml); - supplierModal.show(); + getModal().show(); $.get(urls.updateForm, {id: editingId}, function (html) { console.log('[supplier] updateForm ответ получен'); $('#supplier-modal-body').html(html); @@ -107,7 +106,7 @@ console.log('[supplier] сохранение ответ:', resp); if (resp.success) { shouldReload = true; - supplierModal.hide(); + getModal().hide(); } else if (resp.errors) { $saveBtn.prop('disabled', false); $.each(resp.errors, function (field, messages) {