multiple x-if not working inside x-for directive #3583
Replies: 4 comments 9 replies
-
It's in the documentation, but templates can only have one child. If you need to have two, then wrap them in a dummy element. |
Beta Was this translation helpful? Give feedback.
-
@ekwoka This is quite strange, How I wanted it to be working , it's working good at OLD verison : But the same code i try with Newer version it doesn't work |
Beta Was this translation helpful? Give feedback.
-
@ekwoka How you told in above comment i tried that too in v3.1.x |
Beta Was this translation helpful? Give feedback.
-
Yes, creating an extra div does not solve the problem completely, because it changes the style: Example for printing row elems and on each iteration i can render more than one element. <div class="flex flex-row"> <!-- tailwind code for row style -->
<template x-for="item in items">
<div> <!-- THIS BREAKS MY ROW STYLE IF THE 2 INNER IFs ARE TRUE -->
<template x-if="...condition 1...">
...
</template>
<template x-if="...condition 2...">
...
</template>
</div>
</template>
</div> |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello ,
Issue: When i try to have multiple x-if's inside x-for only the top-most x-if renders the below one doesn't
version: 3.12.1
build (npm/script) : script tag
Code:
Dom Preview:
The below template with x-if="st.type==='img'" is not rendering
I have re-checked my data also, everything is correct,
Beta Was this translation helpful? Give feedback.
All reactions