How can I set the data of Alpine component from outside of ANY Alpine component? #4301
Replies: 1 comment 2 replies
-
generally, you don't it defeats the idea of components.
Are you sure? This seems doubtful. It's likely an XY problem. but to most directly answer the question... The most common is that you would just use a store, since Stores are easily addressable from outside the alpine context. It's globally shared, so you update it there. To update the data in an arbitrary component context, when all you have is the |
Beta Was this translation helpful? Give feedback.
-
I have a user modal that shows the data of any user dynamically. Here is an example to simplify the requirement
How can I set the
user
property here? Please note that when setting the property I need to set it outside of any Alpine component scope. So in other words the function call cannot happen in any alpine component whether the one that I am intending to change the data for or any other component.Alpine documentation is full of examples of changing the data within the component itself, which I don't find useful in this case.
Beta Was this translation helpful? Give feedback.
All reactions