I use the dadata service to get hints when entering an address followed by decomposition of the full address into its components (Region, City, Street, etc.). On the PC version of the application, everything works well, but when you try to do the same from a mobile device, when you enter the address, prompts appear, but when you click on it, the address is not entered into the field and the fields are not decomposed. I use the code from the example on dadata, I will attach it below. I understand it does not work onSelect. Tell me please, how can I solve this problem? Below is an example of the code used.

$("[Data-test-ID = 'Input_Address']").suggestions({ token: "Тут ключ API", type: "ADDRESS", count: 5, /* Вызывается, когда пользователь выбирает одну из подсказок */ onSelect: function(suggestion) { alert("Обработчик сработал"); console.log(suggestion); $("[Data-test-ID = 'Full1']").val(suggestion.unrestricted_value); $("[Data-test-ID = 'Flat1']").val(suggestion.data.block); $("[Data-test-ID = 'City1']").val(suggestion.data.city); if (suggestion.data.city == null) { $("[Data-test-ID = 'City1']").val(suggestion.data.settlement); } $("[Data-test-ID = 'Street1']").val(suggestion.data.street); $("[Data-test-ID = 'House1']").val(suggestion.data.house); $("[Data-test-ID = 'Region1']").val(suggestion.data.region); $("[Data-test-ID = 'postal_code1']").val(suggestion.data.postal_code); $("[Data-test-ID = 'ID1']").val(sek); } }); 
  • при нажатии на нее адрес не заносится в поле и не происходит декомпозиция по полям - where is the whole code? - Denis Heavenly
  • I am sorry, I fixed it - mhz
  • And where is the html code? - Denis Heavenly
  • In general, it is quite possible that on the mobile in the suggestions widget there is no handling of the tap event, but there is only a click - Boris Ustyantsev

1 answer 1

First, make sure that the data arrives: we cannot use console.info , so take an alert

 $("[Data-test-ID = 'Input_Address']").suggestions({ token: "Тут ключ API", type: "ADDRESS", count: 5, /* Вызывается, когда пользователь выбирает одну из подсказок */ onSelect: function(suggestion) { alert(suggestion.unrestricted_value); alert(suggestion.data.block); alert(suggestion.data.city); alert(suggestion.data.street); alert(suggestion.data.house); alert(suggestion.data.region); alert(suggestion.data.postal_code); } }); 

But I am sure that everything is in order here. Your problem most likely is to write the identifier in different case. If you write data-Text="text" the browser will convert it to lower case, so you will have to work not with data-Text , but with data-text .

Put your identifiers in lower case and I think the problem will disappear.