x-ref is undefined for function call inside a x-for loop even though it's inside the x-data scope #4648
Unanswered
BramMortier
asked this question in
5. Bugs
Replies: 1 comment
-
|
x-for defines a new root, and I'm pretty sure refs only go on their directly contained component, not children. you could directly assign that element to a value on the component to expose it |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have some filtering logic where i use the setFilter function to adjust the filters and every time this function is called the renderResults function gets triggered. This function replaces the results content in the x-ref="results" div. This logic works as intended
the x-data is defined outside the x-ref so the scope should be correct. The strange thing is when i call the setFilter function from within this loop inside the filters component. this.$refs.results is undefined and the renderResults function fails to replace the content.
so I tried console.log $refs.results after the setFilter call inside the template and not only does it log the correct element everything works now! When i remove the console log it stops working again. I have no clue why.
this is the difference between working and crashing
Beta Was this translation helpful? Give feedback.
All reactions