I have nested alpine.js x-data tags, where the nested tag depends on the parent, like the following:
<div x-data="{foo: 1234}">
<input x-model="foo" type="number">
<div x-text="`foo = ${foo}`"></div>
<div x-data="{bar: [foo*1, foo*2, foo*3]}">
<template x-for="point in bar">
<div x-text="point"></div>
</template>
</div>
</div>
At the moment, it starts okay, with the output showing:
foo = 1234
1234
2468
3702
However, upon changing the input, the bar values do not update:
foo = 1235
1234
2468
3702
Is it possible to have the nested x-data bar value update dynamically when foo is changed in the parent?
Here is a working example: https://codepen.io/manticorp/pen/RNPBrPK