diff --git a/myproject/orders/static/orders/js/customer_select2.js b/myproject/orders/static/orders/js/customer_select2.js index 074daea..a25bdd5 100644 --- a/myproject/orders/static/orders/js/customer_select2.js +++ b/myproject/orders/static/orders/js/customer_select2.js @@ -325,14 +325,6 @@ return; } - // Сохраняем текущее значение - const currentValue = $element.val(); - const currentText = $element.find(':selected').text(); - - if (!currentValue) { - $element.empty(); - } - // Инициализация Select2 $element.select2({ theme: 'bootstrap-5', @@ -358,12 +350,8 @@ escapeMarkup: function(markup) { return markup; } }); - // Восстанавливаем значение - if (currentValue && currentText) { - $element.val(currentValue); - } - // Интеграция с DraftCreator при загрузке + const currentValue = $element.val(); if (currentValue && window.DraftCreator) { setTimeout(function() { window.DraftCreator.triggerDraftCreation(); diff --git a/myproject/orders/templates/orders/order_form.html b/myproject/orders/templates/orders/order_form.html index 7e8a861..0d71cff 100644 --- a/myproject/orders/templates/orders/order_form.html +++ b/myproject/orders/templates/orders/order_form.html @@ -164,7 +164,14 @@ data-ajax-url="{% url 'customers:api-search-customers' %}" data-create-url="{% url 'customers:api-create-customer' %}" data-modal-id="createCustomerModal"> - {{ form.customer.value|default:'' }} + {% if form.customer.value %} + + {% endif %} {% endif %} {% if form.customer.errors %}