[TASK] fix issues with destination
This commit is contained in:
@ -15,6 +15,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
initChoices();
|
||||
initBoatActions();
|
||||
selectBoatChange();
|
||||
addRelationMagic(<HTMLElement>document.querySelector('body'));
|
||||
});
|
||||
|
||||
function selectBoatChange() {
|
||||
@ -307,15 +308,15 @@ function initTripSidebar(triggerElement: HTMLElement) {
|
||||
|
||||
function addRelationMagic(bodyElement: HTMLElement) {
|
||||
const fields = bodyElement.querySelectorAll('.set-distance-js');
|
||||
|
||||
if(fields) {
|
||||
Array.prototype.forEach.call(fields, (field: HTMLInputElement) => {
|
||||
if(field.dataset.relation){
|
||||
const relatedField = <HTMLInputElement>bodyElement.querySelector('#' + field.dataset.relation);
|
||||
|
||||
if(relatedField) {
|
||||
field.addEventListener('input', (e) => {
|
||||
e.preventDefault();
|
||||
const dataList = <HTMLDataListElement>document.getElementById('destinations');
|
||||
const dataList = <HTMLDataListElement>document.querySelector('#destinations');
|
||||
if(dataList) {
|
||||
var option = Array.prototype.find.call(dataList.options, function(option) {
|
||||
return option.value === field.value;
|
||||
|
Reference in New Issue
Block a user