-
I have 2 widgets in a Page. The first widget displays a list of items names. The other widget displays details of the selected item in the first widget. Similar to filtering mecanism for piece-type. How can I implements this kind of reactivity of widgets client-side ? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
Not sure if I can give the best answer to this, but... What type of info is the second widget displaying and does it have to be two widgets? At first blush, I'm guessing you would have to use some front-end JS to listen to the one widget and then add data to the second widget. |
Beta Was this translation helpful? Give feedback.
-
Generally speaking, Apostrophe has very few opinions about frontend JavaScript. If you want to use a reactive library like Vue or React to implement widget players, you can do that, or you can write vanilla JavaScript. One challenge is that two separate widgets occupy separate parts of the DOM so you can't just put them in the same Vue or React app. A solution to that is to use a reactive store library like Vuex or Redux, with a single instance shared by all apps in the page. Another challenge is that, currently, there is a bug in vue-loader that makes it difficult to use Vue 2 and Vue 3 in the same project, even though in theory they should coexist. Since Apostrophe 3 uses Vue 2, we currently use Vue 2 for frontend code as well if choosing to use a frontend framework at all for a project. The vanilla JavaScript solution might be easiest for your project though. Add appropriate |
Beta Was this translation helpful? Give feedback.
-
Thank you for.
Actually I implemented some experiments using vanilla js.
I would like to test with vuejs and vuex ou pinia. But I don't have any
idea on how I can use vuejs to implement reactive widgets.
Some tips or examples ? Really appreciated. As I am new in Apostrophecms
community, I don't know how and where vuejs is or can be used client or
server side. Is there documentation for that aspect?
Best regards
|
Beta Was this translation helpful? Give feedback.
-
Hi. Any update ? #3913 |
Beta Was this translation helpful? Give feedback.
Generally speaking, Apostrophe has very few opinions about frontend JavaScript. If you want to use a reactive library like Vue or React to implement widget players, you can do that, or you can write vanilla JavaScript.
One challenge is that two separate widgets occupy separate parts of the DOM so you can't just put them in the same Vue or React app. A solution to that is to use a reactive store library like Vuex or Redux, with a single instance shared by all apps in the page.
Another challenge is that, currently, there is a bug in vue-loader that makes it difficult to use Vue 2 and Vue 3 in the same project, even though in theory they should coexist. Since Apostrophe 3 uses Vue 2, we curr…