Populate alpinejs variable in script -

Hi guys!

How can I populate an alpinejs variable within a script, as shown below?

<input type=“file” x-ref=“image”

@change="

const reader = new FileReader()

reader.onload = (event) => {

imagePreview = event.target.result

}

reader.readAsDataURL($refs.image.files[0])

How can I populate an alpinejs variable here?

sample:

title = ‘my teste’

">