Spring-Boot + Thymeleaf, load data into Bootstrap modal window

Asked

Viewed 848 times

0

Good afternoon! I am using spring-boot and Thymeleaf to develop a java application, I would like to know how to load records to the modal window of bootstrap by clicking on the link of the table that lists the records.

Example: On the users query screen, I have 3 buttons view, edit, delete. The preview button will only load the selected user data in the modal window, not allowing editing. The edit button will do the same thing, but will allow the user to edit the data through the form. What is the best way to do this? I appreciate any help, I’m starting now and I’m a little lost. Hugs!

2 answers

1

if you’re using bootstrap there is an event called show.bs.modal, it is fired every time a modal appears, da pra vc build something inside your modal by clicking on the buttons of your table.

you can make a javascript thus

$("SeuModal").on("show.bs.modal",function(){
    //coloque seu codigo aqui

});
  • Thanks for the reply, but I solved it a few months ago and forgot to update here. hahaha

0

What was the solution? I have a service order registration and need to add the customer, when clicking on magnifying glass I need to open a modal with a list of customers, and click on a button and add this customer in my form So in my form it would look like this: Client:Maria da Silva

  • Hello Ludmylla, unfortunately I no longer own the code of this project, was one of the first I did in the internship in 2017. But in your case, I believe it would be creating the form normally within the modal using Thymeleaf and when selecting the Customer from the list, vc uses the th:onchange function to pick up an object with the full client information and in the form action you call the endpoint/method of your controller that will create the user. Sorry if this doesn’t help much, it’s been a long time since I work with this technology.

  • See if this video helps you https://www.youtube.com/watch?v=8c0OYbtfGa8

Browser other questions tagged

You are not signed in. Login or sign up in order to post.