Commit 4fb6abe1 authored by Mat's avatar Mat

bouton éditer, les datas sont récupérées depuis le json, et on gère le masquage du form

parent 772e6fa0
......@@ -109,6 +109,13 @@
getAJAX(submitURL, function()
{
if (this.readyState === 4 && this.status === 200)
{
let json = JSON.parse(this.responseText);
form.querySelector('#owner_firstname').value = json.firstname;
form.querySelector('#owner_lastname').value = json.lastname;
form.parentNode.classList.remove('hidden');
}
});
});
......@@ -136,7 +143,9 @@
let createBtns = document.querySelectorAll('.btn-create');
createBtns.forEach(function(currentBtn){ // ou for (let currentBtn of createBtns)
currentBtn.addEventListener('click', function(e){ // 'e' veut dire 'event'
currentBtn.addEventListener('click', function(e) { // 'e' veut dire 'event'
form.querySelector('#owner_firstname').value = null;
form.querySelector('#owner_lastname').value = null;
form.parentNode.classList.remove('hidden');
submitURL = Routing.generate('api_owner_create');
});
......@@ -158,9 +167,11 @@
e.preventDefault();
if (this.readyState === 4 && this.status === 200) {
reloadTableOwner();
postAJAX(submitURL, function()
{
reloadTableOwner();
form.parentNode.classList.add('hidden');
}
}, form);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment