diff --git a/myproject/orders/templates/orders/order_form.html b/myproject/orders/templates/orders/order_form.html index 2070ede..46a8c7c 100644 --- a/myproject/orders/templates/orders/order_form.html +++ b/myproject/orders/templates/orders/order_form.html @@ -568,20 +568,26 @@ function initCustomerSelect2() { // Обработчик прямого клика на результаты (для "create option") $customerSelect.on('select2:opening', function(e) { + console.log('9_open. Dropdown открывается, добавляем обработчик клика'); // Добавляем обработчик на клик по результатам в следующем event tick setTimeout(function() { const resultsContainer = document.querySelector('.select2-results'); + console.log('9_search. resultsContainer найден:', !!resultsContainer); if (resultsContainer) { resultsContainer.addEventListener('click', function handleCreateOptionClick(event) { + console.log('9_click. Клик по результатам:', event.target); const target = event.target.closest('.select2-results__option'); + console.log('9_option. Ближайший option:', target); if (!target) return; // Проверяем содержит ли элемент класс customer-create-option const createOptionDiv = target.querySelector('.customer-create-option'); + console.log('9_create. create option найден:', !!createOptionDiv); if (createOptionDiv) { console.log('9c. Клик на create option напрямую'); // Получаем текст опции const fullText = target.textContent.trim(); + console.log('9_text. Полный текст:', fullText); // Извлекаем поисковый текст (удаляем "Создать клиента: ") const searchText = fullText.replace(/^\s*[\s\S]+?:\s*"([^"]*)"\s*$/, '$1') || fullText;