How can I keep the modal open when I click the submit button?
I want to reload an existing modal form when I click submit. The code form is in fragment/header, and when I click the "login" button, the modal shows up. The issue is that in views/loginForm, I have the same modal code, but it requires the button to open the modal again. Instead, I want to refresh the existing modal or immediately open the same model on another page.
<a class="nav-link" data-toggle="modal" data-target="#demoModal" href="/login">Logowanie</a>
Modal:
<div class="modal" id="demoModal" data-backdrop="static">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title ">Please confirm!</h2>
<button type="button" class="close" data-dismiss="modal">
<span>×</span>
</button>
</div>
<div class="alert alert-danger col-12" th:if="${param.error}">
<h2 class="">Invalid Email or Password</h2>
</div>
<form th:action="@{login}" method="post">
<div class="modal-body">
<div class="form-group">
<label for="email" class="form-control-label">Email</label>
<input type="text"
class="form-control"
id="email" name="username"/>
</div>
<div class="form-group">
<label for="password" class="form-control-label">Password</label>
<input type="password"
class="form-control"
id="password" name="password"/>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary" >Zalogj sie</button>
</div>
</form>
</div>
</div>
</div>
On the @GetMapping
@GetMapping("/login")
public String showLoginForm() {
return "views/loginForm";
}
When the user enters the wrong password, they are redirected to:
http://localhost:8080/login?error
However, this action closes my modal.