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");
|
||||
if (newReportForm) {
|
||||
newReportForm.addEventListener("submit", function(event) {
|
||||
event.preventDefault();
|
||||
if (event.target.classList.contains("new-report")) {
|
||||
const url = getEndpointDomain() + "api/v1/report";
|
||||
const payload = JSON.stringify({ "title": event.target.elements.title.value });
|
||||
console.log("Payload:\n" + payload);
|
||||
const type = reportType.NEW;
|
||||
postDataToEndpoint(url, payload, createReportForm, type);
|
||||
}
|
||||
this.reset();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
<h3>Create a new report</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form class="form new-report" autocomplete="off">
|
||||
<form class="form new-report-form" autocomplete="off">
|
||||
<div class="form-group">
|
||||
<label for="title">Report title:</label>
|
||||
<input type="text" class="form-control" name="title" id="title">
|
||||
|
|
Loading…
Reference in a new issue