Thymeleaf Iteration with buttons, every button onclick gets called simultaniosly
Foreach has 12 items, they all get displayed with correct id, but when i tap on a button the onlcik gets called for all 12 entrys at the same time?
25 Replies
⌛
This post has been reserved for your question.
Hey @' .•TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.KIΛ.RΛR ’•. '! Please use
/closeor the
Close Post` button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
can you show html
from chromes inspect element
i cutted the hmtl bc i dont think the other parts would matter (in the code exmaple above
huh i dont see onclick on rendered html
is this nested in form tag?
idk thymleaf stuff ig
yes
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
;-;
can you share code pen with form and two elements
so apparantly it calls the func for all element when the iste is loaded?
Controller
Form
Log when site is loaded
@' .•
KIΛ.RΛR ’•. ' show your
POST:/reservation` method too
@straightface
can you provide mcve on public github?
I am having hard time making sense of your issue
GitHub
GitHub - DragonCat4012/web-thymeleaf
Contribute to DragonCat4012/web-thymeleaf development by creating an account on GitHub.
it not the project itself since i cant share it i think, but i recreated my issue in this starter project from https://github.com/mkyong/spring-boot
GitHub
GitHub - mkyong/spring-boot: List of Spring Boot Tutorials
List of Spring Boot Tutorials. Contribute to mkyong/spring-boot development by creating an account on GitHub.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
Cool bot …
ok i got it now, so you cant call
form.add(e)
the way you are doing, since thymeleaf is trying to create html that is understood by chrome.
thymeleaf executes java code on server and then spits out html
this is how thymeleaf spits out html
form.a() returns int
now
@' .•` KIΛ.RΛR ’•. 'when opening the site it still calls a for all entries ;-;
and when i click on one still all get triggered
@straightface
if thats not how i should do that, is tehre a way to call a function the form without a get/post request? bc io ndont want spring to relaod the entire siude and remove all the form inpust again ;-;
yeah you are looking for ajax call
you will need to create an endpoint that receives this request and does stuff
ah oki thx!
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.