Ha, tohle jsem chtěl tady
This commit is contained in:
parent
a8b7788d35
commit
4121de260e
2 changed files with 20 additions and 22 deletions
|
@ -25,3 +25,23 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
[]]
|
[]]
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function zmenStavKorektury(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
oprava = event.target.parentElement.parentElement.parentElement.parentElement;
|
||||||
|
|
||||||
|
const data = new FormData(event.target);
|
||||||
|
data.append("action", event.submitter.value);
|
||||||
|
|
||||||
|
fetch("{% url 'korektury_api_oprava_stav' %}", {method: "POST", body: data})
|
||||||
|
.then(response => {
|
||||||
|
if (!response.ok) {alert("Něco se nepovedlo:" + response.statusText);}
|
||||||
|
else response.json().then(data => {oprava.dataset.opravastatus = data["status"]; oprava.previousElementSibling.dataset.opravastatus = data["status"]});
|
||||||
|
})
|
||||||
|
.catch(error => {alert("Něco se nepovedlo:" + error);});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const form of document.querySelectorAll(".corr-buttons form")) form.addEventListener('submit', async event => { zmenStavKorektury(event); });
|
||||||
|
</script>
|
||||||
|
|
|
@ -42,25 +42,3 @@
|
||||||
<hr>
|
<hr>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function zmenStavKorektury(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
oprava = event.target.parentElement.parentElement.parentElement.parentElement;
|
|
||||||
|
|
||||||
const data = new FormData(event.target);
|
|
||||||
data.append("action", event.submitter.value);
|
|
||||||
|
|
||||||
fetch("{% url 'korektury_api_oprava_stav' %}", {method: "POST", body: data})
|
|
||||||
.then(response => {
|
|
||||||
if (!response.ok) {alert("Něco se nepovedlo:" + response.statusText);}
|
|
||||||
else response.json().then(data => {oprava.dataset.opravastatus = data["status"]; oprava.previousElementSibling.dataset.opravastatus = data["status"]});
|
|
||||||
})
|
|
||||||
.catch(error => {alert("Něco se nepovedlo:" + error);});
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const form of document.querySelectorAll(".corr-buttons form")) form.addEventListener('submit', async event => { zmenStavKorektury(event); });
|
|
||||||
</script>
|
|
||||||
|
|
Loading…
Reference in a new issue