Slide 35
Slide 35 text
2
データと UI
の同期が手動!!
2
データと UI
の同期が手動!!
/**
*
指定した
TODO
削除と
UI
反映をする
* @param {*} id TODO
の
id
*/
handleClickDeleteTask(id) {
const buttonEl = document.getElementById(`button-${id}`);
buttonEl.addEventListener("click", () => {
fetch(`http://localhost:3000/tasks/${id}`, {
method: "DELETE",
headers: {
"X-CSRF-Token": Rails.csrfToken(),
"content-type": "application/json",
},
})
.then((res) => {
return res.json();
})
.then((json) => {
this.flash(json);
});
});
}