I need to change the value of myData variable to whatever is the current value of the select tag.
I am currently using this and it works but is there a cleaner way in Alpine for doing this?
<div x-data="{ myData: []}">
<select id="mySelect" @change="myData = document.getElementById('mySelect').value">
<option>2021</option>
<option>2022</option>
</select>
</div>
Figured it out using x-model. So the cleaner version of the above code is simply:
<div x-data="{ myData: []}">
<select x-model="myData">
<option>2021</option>
<option>2022</option>
</select>
</div>