Commit 2b580c42 authored by Mat's avatar Mat

event sur le bouton refresh, met le getAJAX dans une fonction

parent 470c49e2
...@@ -68,6 +68,10 @@ ...@@ -68,6 +68,10 @@
let grid = document.querySelector('div#grid-images'); let grid = document.querySelector('div#grid-images');
let imagesURL = Routing.generate('api_image_read'); let imagesURL = Routing.generate('api_image_read');
function reloadGridImage()
{
grid.innerHTML = null;
AJAX('GET', imagesURL, function(request) AJAX('GET', imagesURL, function(request)
{ {
let json = JSON.parse(request.responseText); let json = JSON.parse(request.responseText);
...@@ -90,9 +94,12 @@ ...@@ -90,9 +94,12 @@
owner.innerHTML = json[i].owner.firstname + ' ' + json[i].owner.lastname; owner.innerHTML = json[i].owner.firstname + ' ' + json[i].owner.lastname;
div.appendChild(owner); div.appendChild(owner);
/* /*
* * Editer une ligne du tableau (update),
* charge les données dans le formulaire
*/ */
let editBtn = document.createElement('button'); let editBtn = document.createElement('button');
editBtn.classList.add('btn', 'btn-primary'); editBtn.classList.add('btn', 'btn-primary');
editBtn.dataset.imageId = json[i].id; editBtn.dataset.imageId = json[i].id;
...@@ -103,9 +110,11 @@ ...@@ -103,9 +110,11 @@
}); });
modify.appendChild(editBtn); modify.appendChild(editBtn);
/* /*
* * Effacer une ligne du tableau (delete)
*/ */
let deleteBtn = document.createElement('button'); let deleteBtn = document.createElement('button');
deleteBtn.classList.add('btn', 'btn-danger'); deleteBtn.classList.add('btn', 'btn-danger');
deleteBtn.dataset.imageId = json[i].id; deleteBtn.dataset.imageId = json[i].id;
...@@ -120,6 +129,23 @@ ...@@ -120,6 +129,23 @@
grid.appendChild(div); grid.appendChild(div);
} }
}); });
}
reloadGridImage();
/*
* Recharge le tableau (read)
*/
let reloadBtns = document.querySelectorAll('a.btn-reload');
reloadBtns.forEach(function(reloadBtn)
{
reloadBtn.addEventListener('dblclick', function(e)
{
reloadGridImage();
});
});
</script> </script>
......
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