Transitions without x-for? #587
karls
started this conversation in
4. General
Replies: 1 comment 7 replies
-
Hi @karls - from what I can tell, adding an The |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi Alpinists!
I didn't know whether what I am about to discuss/ask would qualify as a feature request — perhaps it's possible already and I just don't know how.
I came across a situation where I want to use transitions without
x-for
. As far as I understand, that's not really possible currently. The situation I have is that there's a menu of items and selecting an item displays some data/contents somewhere else. I would like the display area to transition in and out smoothly as different items are selected. The current approach that works is to wrap the display are in a<transition x-for="item in [items[selectedItem]]">
which feels a bit hacky. I initially tried adding:key="selectedItem
to the display area itself, thinking that it would trigger transitions asselectedItem
changes.I am basically asking:
:key="..."
which would trigger transitions withoutx-for
?I've put together a codepen with some comments here: https://codepen.io/krlst/pen/zYrNpzb?editors=1010.
PS! After a bunch of time in SPA land I am exploring traditional server-rendered HTML pages with Alpine.js added in for interactivity. What a breath of fresh air!
Beta Was this translation helpful? Give feedback.
All reactions