Fix form event listener
This commit is contained in:
parent
da50627f51
commit
5427c026cf
2 changed files with 8 additions and 6 deletions
|
@ -419,13 +419,15 @@ document.addEventListener("click", function(event) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
document.addEventListener("submit", function(event) {
|
const newReportForm = document.querySelector(".new-report-form");
|
||||||
event.preventDefault();
|
if (newReportForm) {
|
||||||
if (event.target.classList.contains("new-report")) {
|
newReportForm.addEventListener("submit", function(event) {
|
||||||
|
event.preventDefault();
|
||||||
const url = getEndpointDomain() + "api/v1/report";
|
const url = getEndpointDomain() + "api/v1/report";
|
||||||
const payload = JSON.stringify({ "title": event.target.elements.title.value });
|
const payload = JSON.stringify({ "title": event.target.elements.title.value });
|
||||||
console.log("Payload:\n" + payload);
|
console.log("Payload:\n" + payload);
|
||||||
const type = reportType.NEW;
|
const type = reportType.NEW;
|
||||||
postDataToEndpoint(url, payload, createReportForm, type);
|
postDataToEndpoint(url, payload, createReportForm, type);
|
||||||
}
|
this.reset();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
<h3>Create a new report</h3>
|
<h3>Create a new report</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form class="form new-report" autocomplete="off">
|
<form class="form new-report-form" autocomplete="off">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="title">Report title:</label>
|
<label for="title">Report title:</label>
|
||||||
<input type="text" class="form-control" name="title" id="title">
|
<input type="text" class="form-control" name="title" id="title">
|
||||||
|
|
Loading…
Reference in a new issue