0.0.30 upd autocomlitev2.js
This commit is contained in:
@@ -16,7 +16,7 @@ function searchTown(el){
|
|||||||
// enctype: 'json',
|
// enctype: 'json',
|
||||||
data: JSON.stringify(get_address_point),
|
data: JSON.stringify(get_address_point),
|
||||||
success: function(data){
|
success: function(data){
|
||||||
return search(data)
|
return insertSearchList(data, el.name)
|
||||||
},
|
},
|
||||||
error: function (data){
|
error: function (data){
|
||||||
console.log('Error')
|
console.log('Error')
|
||||||
@@ -42,35 +42,37 @@ function selectItemAddrPoint(id, name){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// function search(data) {
|
function insertSearchList(data, ctrl_name) {
|
||||||
//
|
|
||||||
// let ac = document.querySelector("#id_from_address_point_txt");
|
// 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) {
|
// if (ac.value.length > 2) {
|
||||||
//
|
// //
|
||||||
// let res_data = data.data
|
// // let res_data = data.data
|
||||||
//
|
// //
|
||||||
// var divs = res_data.map(function(r, i) {
|
// // var divs = res_data.map(function(r, i) {
|
||||||
// airport_name = "'"+r.iata_code + " - " + r.name+"'";
|
// // airport_name = "'"+r.iata_code + " - " + r.name+"'";
|
||||||
//
|
// //
|
||||||
// return '<div onclick="selectItemAddrPoint('+ r.id+', '+ airport_name +')" class="autocomplete-result" data-index="'+ i +'" data-id="'+ r.id + '">'
|
// // return '<div onclick="selectItemAddrPoint('+ r.id+', '+ airport_name +')" class="autocomplete-result" data-index="'+ i +'" data-id="'+ r.id + '">'
|
||||||
// + '<div><b>'+ r.iata_code +'</b> - '+ r.name +'</div>'
|
// // + '<div><b>'+ r.iata_code +'</b> - '+ r.name +'</div>'
|
||||||
// + '<div class="autocomplete-location">'+ r.city__name +', '+ r.city__country__name +'</div>'
|
// // + '<div class="autocomplete-location">'+ r.city__name +', '+ r.city__country__name +'</div>'
|
||||||
// + '</div>';
|
// // + '</div>';
|
||||||
// });
|
// // });
|
||||||
//
|
// //
|
||||||
//
|
// //
|
||||||
// let input_list = document.querySelector(".input_list");
|
// //
|
||||||
// input_list.classList.toggle("show")
|
// //
|
||||||
// input_list.innerHTML = divs
|
// //
|
||||||
//
|
// // // .html(divs.join(''))
|
||||||
//
|
// // // .attr('data-highlight', selectedIndex);
|
||||||
// // .html(divs.join(''))
|
// //
|
||||||
// // .attr('data-highlight', selectedIndex);
|
|
||||||
//
|
|
||||||
// } else {
|
// } else {
|
||||||
// numResults = 0;
|
// numResults = 0;
|
||||||
// let divs = [];
|
// let divs = [];
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
// }
|
}
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
<label for="id_from_address_point">{{ form.fields.from_address_point.label }}</label>
|
<label for="id_from_address_point">{{ form.fields.from_address_point.label }}</label>
|
||||||
<input type="number" name="from_address_point" id="id_from_address_point" hidden />
|
<input type="number" name="from_address_point" id="id_from_address_point" hidden />
|
||||||
<input oninput="searchTown(this)" type="text" name="from_address_point_txt"{% if form.fields.from_address_point.required %} required{% endif %} id="id_from_address_point_txt">
|
<input oninput="searchTown(this)" type="text" name="from_address_point_txt"{% if form.fields.from_address_point.required %} required{% endif %} id="id_from_address_point_txt">
|
||||||
<div class="input_list" name="from_address_point_txt">
|
<div class="input_list" name="from_address_point_txt_list">
|
||||||
{% include 'widgets/w_ac_input_address_point.html' %}
|
{% include 'widgets/w_ac_input_address_point.html' %}
|
||||||
</div>
|
</div>
|
||||||
{% if form.errors and form.errors.from_address_point %}
|
{% if form.errors and form.errors.from_address_point %}
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
<label for="id_to_address_point">{{ form.fields.to_address_point.label }}</label>
|
<label for="id_to_address_point">{{ form.fields.to_address_point.label }}</label>
|
||||||
<input type="number" name="to_address_point" id="id_to_address_point" hidden />
|
<input type="number" name="to_address_point" id="id_to_address_point" hidden />
|
||||||
<input oninput="searchTown(this)" type="text" name="to_address_point_txt"{% if form.fields.to_address_point.required %} required{% endif %} id="id_to_address_point"/>
|
<input oninput="searchTown(this)" type="text" name="to_address_point_txt"{% if form.fields.to_address_point.required %} required{% endif %} id="id_to_address_point"/>
|
||||||
<div class="input_list" name="from_address_point_txt">
|
<div class="input_list" name="to_address_point_txt_list">
|
||||||
{% include 'widgets/w_ac_input_address_point.html' %}
|
{% include 'widgets/w_ac_input_address_point.html' %}
|
||||||
</div>
|
</div>
|
||||||
{% if form.errors and form.errors.to_address_point %}
|
{% if form.errors and form.errors.to_address_point %}
|
||||||
|
|||||||
Reference in New Issue
Block a user