I am new in vue js. In our app, we have validation if this value is already exists in the database. I want to improve it by making it a dynamic. So I added to put data attribute in my field whenever the user type anything. My value in mthe data attribute is the table where I will check if this value already exist.
Add.vue
<label>Code <span class="required-field">*</span></label>
<input type="text" name="code" @keyup="checkCOACode" v-model="coa_code" class="form-control" :data-table="chart_of_accounts">
Add.vue in my method
checkCOACode(e) {
e.preventDefault();
var code = this.coa_code;
var x = event.target.getAttribute('data-table');
alert(x);
return false;
axios.post("/checkIfCodeExists", {code:code})
.then((response) => {
var code_checker = '';
if (response.data == 0) {
$('.add-chart-of-account').removeAttr('disabled','disabled');
}else{
$('.add-chart-of-account').attr('disabled','disabled');
code_checker = 'Code is already exist';
}
this.coa_checker_result = code_checker;
});
},
My value in my x is null.
Question: How do I get the value of my data attribute?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire