You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there — firstly, thanks for the great plugin, it mostly seems to work brilliantly. One bit of oddness I've just discovered though: When I use $parent in a template element within a child component, it seems to refer to the current component, unless I do $parent.$parent.xyz. I'd tested with the following markup
If I use unique names for the properties, they work as expected, although that seems to defeat the purpose.
Is this expected behaviour? If so, all good — I can confidently use $parent.$parent and understand that it won't regress in a future minor version. It would be nice to have a note in the docs though, if that is the case. If not, then do you know what might be wrong?
Thanks again!
The text was updated successfully, but these errors were encountered:
I think this is a side effect of how Alpine is storing data for each "node" inside of the x-for. The under-the-hood logic is essentially treating each element produced by the x-for as a separate Alpine component, storing the iteration variables as the data, so yes. Unless Alpine.js changes how it is doing this, $parent.$parent will be reliable.
If I need to change it for whatever reason such that it breaks, a new major release will be needed anyway.
Hi there — firstly, thanks for the great plugin, it mostly seems to work brilliantly. One bit of oddness I've just discovered though: When I use $parent in a
template
element within a child component, it seems to refer to the current component, unless I do$parent.$parent.xyz
. I'd tested with the following markuphttps://jsfiddle.net/njpanderson/wbLf9krv/19/
If I use unique names for the properties, they work as expected, although that seems to defeat the purpose.
Is this expected behaviour? If so, all good — I can confidently use
$parent.$parent
and understand that it won't regress in a future minor version. It would be nice to have a note in the docs though, if that is the case. If not, then do you know what might be wrong?Thanks again!
The text was updated successfully, but these errors were encountered: