-
Hi! There is some scope problem inside js getters. const exampleData = () => ({
first: {
show: null,
get input() {
// this.$el -> undefined
return this.$el.parentElement.querySelector('input')
},
},
second: {
show: null,
get input() {
// this.$el -> undefined
return this.$el.parentElement.querySelector('input')
},
},
}) With methods there is no scope problems. |
Beta Was this translation helpful? Give feedback.
Answered by
ekwoka
Jan 21, 2025
Replies: 1 comment 1 reply
-
This is not a problem with Alpine, but a factor of how JS works.
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
BorisKM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is not a problem with Alpine, but a factor of how JS works.
this
refers to the immediate object the method is on, not any other parent.