function createApp () { //добавляем содержимое в html-вёрстку
// прочитать список
studentList = JSON.parse(localStorage.getItem("myKey") ?? '[]');
const container = document.querySelector('.conteiner'); // подключаем контейнер
const tableObj = createTable(); // создаем таблицу
container.append(tableObj.table); // добавляем в разметку созданную таблицу
const addBtn = document.querySelector('.add-btn'); // поключаем кнопку
addBtn.addEventListener('click', () => { // навешиваем событие на кнопку, чтобы при клике срабатывала функция
addStudent(studentsList, tableObj.tbody); // функция добавления студента из формы.
// При каждом обновлении сохраняем
localStorage.setItem("myKey",JSON.stringify(studentsList));
});
// А это не надо
// localStorage.setItem("myKey",JSON.stringify(studentsList));
}
…
<div id="table">
@include('table')
</div>
…
<table>
<tr>
...
</tr>
@foreach ($data as $element)
<tr>
<td>{{ $element['date'] }}</td>
...
</tr>
@endforeach
</table>
Route::get('getTable', function(){
...
return response()->json([
'target' => 'table',
'html' => view('table', [...])->render()
])
});
function getChank(url, data) {
return fetch(url, {
body: data,
}).then(response => response.json())
.then(response => {
const target = document.getElementById(response.target);
target.innerHTML = response.html;
});
}
function showThumbnail($img, href, title) {
$img.attr('src', href);
$img.attr('alt', title);
}
$(".gallery__list").each(function($gallery){
let $largeImg = $gallery.find('.galleru__item-prem');
$gallery.mouseover(function(event){
let thumbnail = event.target.closest('.galleru__item');
if (!thumbnail) return;
showThumbnail($largeImg, thumbnail.href, thumbnail.title);
});
});
function showThumbnail(img, href, title) {
img.src = href;
img.alt = title;
}
document.querySelectorAll('.gallery__list').forEach(function(gallery){
const largeImg = gallery.querySelector('.galleru__item-prem');
if (!largeImg) console.warn('Нет большой картинки');
gallery.addEventListener('mouseover', function(event){
const thumbnail = event.target.closest('.galleru__item');
if (!thumbnail) return;
showThumbnail(largeImg, thumbnail.href, thumbnail.title);
});
});
https://mysite.ru/download/sadlflksdjfkj
'/download/{hash}'