alpine-js: 3.13.10
alpine-requests: 1.0.4
<!-- problem -->
<form x-data="{sample: ''}">
<input type="text" x-model="sample" />
<span x-text="sample"></span>
<!-- binds only to empty sample property -->
<button
type="button"
x-post="{route: '/api', body: JSON.stringify({sample}), headers: {'content-type': 'application/json'}}"
>
Like
</button>
</form>
<!-- workaround -->
<form
x-data="{sample: ''}"
@submit.prevent="$post({route: '/api', body: JSON.stringify({sample}), headers: {'content-type': 'application/json'}})"
>
<input type="text" x-model="sample" />
<span x-text="sample"></span>
<button type="submit">Like</button>
</form>
alpine-js: 3.13.10alpine-requests: 1.0.4