[[oktatas:web:jquery|< jQuery]] ====== jQuery - Táblázat renderelése ====== * **Szerző:** Sallai András * Copyright (c) 2024, Sallai András * Szerkesztve: 2024 * Licenc: [[https://creativecommons.org/licenses/by-sa/4.0/|CC Attribution-Share Alike 4.0 International]] * Web: https://szit.hu ===== A weblap =====
Id Név Település Fizetés
===== Renderelés példa ===== const url = 'http://localhost:8000/employees' var empList = [] $.ajax(url) .done((data) => { console.log(data) empList = data renderTable() }) function renderTable() { empList.forEach(emp => { const tr = $('') tr.append(` ${emp.id} ${emp.name} ${emp.city} ${emp.salary} `) tr.find('.editButton').click( () => editEmployee(emp)) tr.find('.delButton').click( () => deleteEmployee(emp.id)) $('#empsBody').append(tr) }) } function deleteEmployee(id) { console.log('törlés...') console.log(id) } function editEmployee(emp) { console.log('szerkesztés...') console.log(emp.name) }