Why the variable is not found?

Hello! This problem interesting is that kapets. Variable title_ru available, and record no. Why?

<div id="items" class="main__box">
 @foreach($films as $item)
 <div class="main__box--row">
 <div class="main__item--top">{{$item->id}}</div>
 <div class="main__item--top">{{$item->title_ru}}</div>
 <div class="main__item--top">{{$item->title_en}}</div>
 <div class="main__item--top">{{$item->description}}</div>
 <div class="main__item--top">{{$item->keywords}}</div>
 <div class="main__item--top">{{$item->updated_at}}</div>
 <div class="main__item--top">
 <button class="btn btn__change"
 data-action="change" 
data-record="{{$item->id}}"
 data-title_ru="{{$item->title_ru}}" 
 data-title_en="{{$item->title_en}}" 
 data-description="{{$item->description}}" 
 data-keywords="{{$item->keywords}}" 
data-type="{{$item->type}}"
data-updated_at="{{$item->updated_at}}">Edit</button>
 <button class="btn btn__danger" data-action="delete">Delete</button>
</div>
</div>
@endforeach
</div>
<div id="modal" class="modal"></div>

//JS

let ifModalOpen = false;
const handlerChange = (el) => {
if(!el.target.dataset.action){
return;
}

 let {
record
title_ru,
title_en,
description
keywords
type
updated_at,
action,
 } = el.target.dataset;

switch(action){
 case 'change':
 let modal = document.getElementById('modal');
 let html = ";
 html = modalChange(record,title_ru,title_en,description,keywords,updated_at);
modal.classList.add('modal__open');
 modal.innerHTML = html;
 ifModalOpen = true;
break;
}
}
const onCloseModalKey = (e) => {
 if(e.keyCode == 27 && ifModalOpen)
{
modal.classList.remove('modal__open');
 ifModalOpen = false;
 }else if(e.keyCode == 13 && ifModalOpen)
{
 let confDialog = confirm("Confirm?")
 console.log(title_ru); // White car
 console.log(record); // undefined Why?
}
}

document.getElementById('items').addEventListener('click', handlerChange);
document.body.addEventListener('keyup', onCloseModalKey);

modalChange function(record,title_ru,title_en,description,keywords,updated_at)
{
return;
}
March 23rd 20 at 18:49
0 answer

Find more questions by tags JavaScript