diff --git a/static/css/styles.css b/static/css/styles.css index 4003528..4ef3b81 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -997,4 +997,15 @@ form.new_route{ border-bottom-color: #26C9FF; outline: solid 1px #26C9FF; } -/*autocomplete-wrapper END*/ \ No newline at end of file +/*autocomplete-wrapper END*/ + +.input_list{ + display: none; +} + +.input_list.show{ + display:block; + height: 300px; + width: 50%; + overflow: scroll; +} \ No newline at end of file diff --git a/static/js/autocomlitev2.js b/static/js/autocomlitev2.js index a6d20c9..891de52 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 data; + return search(data) }, error: function (data){ console.log('++') @@ -27,27 +27,30 @@ function searchTown(el){ -function search(e) { +function search(data) { - let ac = document.querySelector("#id_from_country") + let ac = document.querySelector("#id_from_address_point") if (ac.value.length > 0) { - let results = searchTown(ac); + let res_data = data.data - var divs = results.map(function(r, i) { + var divs = res_data.map(function(r, i) { return '
' - + '
'+ r.iata +' - '+ r.name +'
' - + '
'+ r.city +', '+ r.country +'
' + + '
'+ 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; - list.html(divs.join('')) - .attr('data-highlight', selectedIndex); + // .html(divs.join('')) + // .attr('data-highlight', selectedIndex); } else { numResults = 0; - list.empty(); + divs.empty(); + } } \ 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 3f4011b..2c10f14 100644 --- a/templates/blocks/profile/b_new_route.html +++ b/templates/blocks/profile/b_new_route.html @@ -39,17 +39,18 @@
- - - {% if form.errors and form.errors.from_country %} - {{ form.errors.from_country }} + + +
+ {% if form.errors and form.errors.from_address_point %} + {{ form.errors.from_address_point}} {% endif %}
- - - {% if form.errors and form.errors.to_country %} - {{ form.errors.to_country }} + + + {% if form.errors and form.errors.to_address_point %} + {{ form.errors.to_address_point }} {% endif %}