x-for for CSP build #2724
-
I've been running into a few issues with the CSP build, most recently the main issue is that the x-for directive isn't working at all from what I can tell. (Neither is x-model, there is an open PR for that to fix it.) Is there any way to iterate data with the CSP build? I even tried If this is something that I could help with a PR I would definitely work on that, but I just want to get some direction first to make sure I start down the right path. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 9 replies
-
I figured out why this isn't working, but I am not quite sure how to fix. The expression evaluator actually does work in the CSP build (so it is properly finding the key/value part of the expression, so that is not the issue at all here). However, the issue comes in when I try to assign x-text using a dot notation to access part of the value object inside the loop. For example: <template x-for="title in item_titles">
<h1 x-text="title"></h1>
</template> Works fine with CSP build. However, this does not: <template x-for="item in items">
<h1 x-text="item.title"></h1>
</template> Is there anybody that can assist in figuring out how to evaluate the bottom Alternatively, we can also add directive(s) for adding arguments to a function. So you could do something like |
Beta Was this translation helpful? Give feedback.
-
I just found a workaround for anybody having this same issue. Hopefully the CSP plugin will be updated to fix these sorts of issues in the future, but here's the workaround:
Then in getItemTitle I just access the item object via |
Beta Was this translation helpful? Give feedback.
-
Hey @MichaelMackus, thanks for sharing your solution! Did you have any further progress on this issue since your last post? I am having the same issue... |
Beta Was this translation helpful? Give feedback.
-
Thanks @MichaelMackus - This worked for me. Is this way of accessing the data context (this.$data.item.title) something that is stable/officially supported? |
Beta Was this translation helpful? Give feedback.
-
Excellent! Thanks.
…On Sun, Nov 3, 2024 at 8:29 AM Eric Kwoka ***@***.***> wrote:
$data is stable.
—
Reply to this email directly, view it on GitHub
<#2724 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALFTAJEDVFQID37SEQZLN7LZ6YQNDAVCNFSM6AAAAABQ4LNEBSVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCMJTGQZTMNY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
I just found a workaround for anybody having this same issue. Hopefully the CSP plugin will be updated to fix these sorts of issues in the future, but here's the workaround:
Then in getItemTitle I just access the item object via
this.$data.item.title
.