Answer the question
In order to leave comments, you need to log in
How to load template from different url without page reload in Thymeleaf?
I need a pop-up modal window with a different template to appear when the button is clicked, but the current html page remains
. In the template, I have a button that calls a method in the controller:
<a data-modal-target="#modal" th:href="@{'/face/' + ${contact.id}}" class="view">
<button class="btn btn-primary"><i class="fa fa-eye"> View</i></button>
</a>
@GetMapping("/face/{id}")
public ModelAndView viewFullFace(@PathVariable(name = "id")int id, Model model) {
List<Contact> listContacts = contactService.getAll();
model.addAttribute("listContacts", listContacts);
ModelAndView mav = new ModelAndView("view_face");
Contact contact = contactService.get(id).orElse(null);
mav.addObject("contact", contact);
return mav;
}
Answer the question
In order to leave comments, you need to log in
Hello!
Learn ajax technology. And also SPA (single page application)
you can just send an ajax request to the server. Return template with already substituted values and show modal window
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question