Pretty new to vuejs here. I need to make an ajax call (key up event) for a text input in an update form (blade laravel), however in the form the input is blank.
My question is: How do I send the input value from the blade template when the form is loaded to the vue data instance (sn)?
The intention is to alert the user if that value (suite_number) already exists in the database.
Thanks in advance!!!
My blade template:
{!! Form::text('suite_number', null, ['class' => 'form-control', 'id' => 'suiteNumberLookup', 'v-on:keyup' => 'getSuiteNumber(suite_number, $event)', 'v-model' => 'sn']) !!}
My Vuejs:
new Vue({
el: '#suiteNumberLookup',
data:
{
sn: 'What should I set here to get the data that\'s loaded in the form?'
},
methods: {
getSuiteNumber(d) {
this.$http.get('/admin/tenantAjax/getSuiteNumberAjax/' + d).then((response) => {
// success callback
//this.tenant = response.data;
if(response.data){
this.loaded = true;
}
console.log(response.data);
}, (response) => {
this.error = response.body;
this.loadErrorMsg = true;
});
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire