• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How to dynamically add/remove rows from a list|table with thymeleaf?

 
Ranch Hand
Posts: 59
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to dynamically add/remove rows from a list|table with thymeleaf?



In the code above, I have a list of contacts. I also have two buttons: one add a new row with new data and the other button remove rows. How should these two be coded?
I have a current code that works however its a mess of javascript. Is there a cleaner way of doing it?

To add a row, I do this:




To remove a row, I do this:


 
Author
Posts: 12
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand that this post is 2 years old, so maybe not relevant anymore. But if I would do this today, I would use https://htmx.org/. That way, you can use Thymeleaf fragments and avoid a lot of the JavaScript.
 
Honk if you love justice! And honk twice for tiny ads!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic