I want to update property a binded (x-model) property on keydown.
But it does not work at all.
Do I something wrong here?
<div x-data="app()" class="w-64">
<input x-ref="textInput" x-model="textInput" x-on:keyup="limitInput($el)" type="text">
</div>
function app() {
return {
textInput: '',
limitInput($el) {
this.textinput = ''
},
}
}
You are limiting the length of the
inputto 0 usingmaxlength="0"this way nothing can be added inside theinput.Also, what are you trying to do with the
limitInputfunction? because calling it onkeydownwill call it before the input is updated with the key pressed, if you want to call it after, usekeyup.