Commit 1c04e218 authored by Mat's avatar Mat

charge le formulaire pour create ou pour update

parent b63e122a
......@@ -114,7 +114,19 @@
editBtn.dataset.membreId = json[i].id;
editBtn.addEventListener('click', function(e)
{
console.log('edit');
let membreId = this.dataset.membreId;
submitURL = Routing.generate('api_membre_update', {'id': membreId});
AJAX('GET', submitURL, function(request)
{
let json = JSON.parse(request.responseText);
form.querySelector('#membre_nom').value = json.nom;
form.querySelector('#membre_prenom').value = json.prenom;
form.querySelector('#membre_email').value = json.email;
form.querySelector('#membre_association').value = json.association.id;
form.parentNode.classList.remove('hidden');
});
});
td6.appendChild(editBtn);
......@@ -142,8 +154,15 @@
let createBtns = document.querySelectorAll('.btn-create');
createBtns.forEach(function(createBtn) {
createBtn.addEventListener('click', function(e) {
createBtn.addEventListener('click', function(e)
{
form.querySelector('#membre_nom').value = null;
form.querySelector('#membre_prenom').value = null;
form.querySelector('#membre_email').value = null;
form.querySelector('#membre_association').value = null;
form.parentNode.classList.remove('hidden');
submitURL = Routing.generate('api_membre_create');
});
});
......
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