diff --git a/static/js/autocomlitev2.js b/static/js/autocomlitev2.js index 3943588..79001a4 100644 --- a/static/js/autocomlitev2.js +++ b/static/js/autocomlitev2.js @@ -16,7 +16,7 @@ function searchTown(el){ // enctype: 'json', data: JSON.stringify(get_address_point), success: function(data){ - return search(data) + return insertSearchList(data, el.name) }, error: function (data){ console.log('Error') @@ -42,35 +42,37 @@ function selectItemAddrPoint(id, name){ } -// function search(data) { -// -// let ac = document.querySelector("#id_from_address_point_txt"); +function insertSearchList(data, ctrl_name) { + + // let ac = document.querySelector("#id_from_address_point_txt"); + let divs = data.res_search_list; + let input_list = document.querySelector(".input_list[name=ctrl_name]"); + input_list.classList.toggle("show"); + input_list.innerHTML = divs // // if (ac.value.length > 2) { -// -// let res_data = data.data -// -// var divs = res_data.map(function(r, i) { -// airport_name = "'"+r.iata_code + " - " + r.name+"'"; -// -// return '
' -// + '
'+ r.iata_code +' - '+ r.name +'
' -// + '
'+ r.city__name +', '+ r.city__country__name +'
' -// + '
'; -// }); -// -// -// let input_list = document.querySelector(".input_list"); -// input_list.classList.toggle("show") -// input_list.innerHTML = divs -// -// -// // .html(divs.join('')) -// // .attr('data-highlight', selectedIndex); -// +// // +// // let res_data = data.data +// // +// // var divs = res_data.map(function(r, i) { +// // airport_name = "'"+r.iata_code + " - " + r.name+"'"; +// // +// // return '
' +// // + '
'+ r.iata_code +' - '+ r.name +'
' +// // + '
'+ r.city__name +', '+ r.city__country__name +'
' +// // + '
'; +// // }); +// // +// // +// // +// // +// // +// // // .html(divs.join('')) +// // // .attr('data-highlight', selectedIndex); +// // // } else { // numResults = 0; // let divs = []; // // } -// } \ No newline at end of file +} \ 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 a4fb184..88500de 100644 --- a/templates/blocks/profile/b_new_route.html +++ b/templates/blocks/profile/b_new_route.html @@ -42,7 +42,7 @@ -
+
{% include 'widgets/w_ac_input_address_point.html' %}
{% if form.errors and form.errors.from_address_point %} @@ -53,7 +53,7 @@ -
+
{% include 'widgets/w_ac_input_address_point.html' %}
{% if form.errors and form.errors.to_address_point %}