From 57c6badfa96767632ab35cea337c241648567bd8 Mon Sep 17 00:00:00 2001 From: ArtemB Date: Thu, 20 Jul 2023 18:58:12 +0300 Subject: [PATCH] 0.0.28 upd autocomlitev2.js, almost good --- static/js/autocomlitev2.js | 25 ++++++++++++++++------- templates/blocks/profile/b_new_route.html | 9 ++++---- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/static/js/autocomlitev2.js b/static/js/autocomlitev2.js index 74ad48f..5287eea 100644 --- a/static/js/autocomlitev2.js +++ b/static/js/autocomlitev2.js @@ -25,32 +25,43 @@ function searchTown(el){ }); } +function selectItemAddrPoint(id, name){ + let ap_txt_cont = document.querySelector("#id_from_address_point_txt"); + let ap_cont = document.querySelector("#id_from_address_point"); + ap_txt_cont.value = name; + ap_cont.value = id; +} function search(data) { - let ac = document.querySelector("#id_from_address_point") + let ac = document.querySelector("#id_from_address_point_txt"); - if (ac.value.length > 0) { + if (ac.value.length > 2) { let res_data = data.data var divs = res_data.map(function(r, i) { - return '
' + airport_name = "'"+r.iata_code + " - " + r.name+"'"; + + return '
' + '
'+ r.iata_code +' - '+ r.name +'
' + '
'+ r.city__name +', '+ r.city__country__name +'
' + '
'; }); - divs.attr('data-highlight', selectedIndex); - document.querySelector(".input_list").innerHTML = divs - selectedIndex = -1; + + let input_list = document.querySelector(".input_list"); + input_list.classList.toggle("show") + input_list.innerHTML = divs + + // .html(divs.join('')) // .attr('data-highlight', selectedIndex); } else { numResults = 0; - divs.empty(); + let divs = []; } } \ No newline at end of file diff --git a/templates/blocks/profile/b_new_route.html b/templates/blocks/profile/b_new_route.html index 2c10f14..95efad6 100644 --- a/templates/blocks/profile/b_new_route.html +++ b/templates/blocks/profile/b_new_route.html @@ -40,11 +40,12 @@
- -
+ + +
{% if form.errors and form.errors.from_address_point %} - {{ form.errors.from_address_point}} - {% endif %} + {{ form.errors.from_address_point}} + {% endif %}