1000 event listners got created in this code? #1129
-
Hi, with following code, does Alpine call addEventListener() 1000 times? not a good practice when the number is getting big?
|
Beta Was this translation helpful? Give feedback.
Answered by
KevinBatdorf
Feb 24, 2021
Replies: 1 comment
-
That's correct, it's probably not a good idea to write your code like that. Instead you can do something like this: <div x-data="" x-on:click="alert($event.target.textContent)">
<template x-for="i in 1000">
<span x-text="i"></span>
</template>
</div> |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
HugoDF
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's correct, it's probably not a good idea to write your code like that. Instead you can do something like this: