I have an input text with typeahead that I use to search for a user
This I do through a component of vue, the template is:
<template>
<div>
<label for="">Buscar Usuario</label>
<input type="text" class="form-control search-user" required="" placeholder="Usuario" autocomplete="off"/>
<input type="hidden" name="id_user" required="" v-model="user"/>
</div>
</template>
<script>
export default {
data() {
return {
user: ''
}
},
mounted() {
$('.search-user').typeahead({
source: function (query, result) {
return $.post("/FinDraT/users/getUsersTypeAhead", {query: query}, function (data) {
return result(data);
});
},
updater: function (item) {
this.user = item.id;
return item;
}
});
}
}
The problem is that when selecting the user, in the updater method I want to set the id in the hidden input that I then use it to save the user in the model I am in.
The input hidden probe with v-model: "user",: value="user" and none of them set the value