2

I have been struggling with this for way too long now. Vue throws an error that name is not defined. It is not defined from start but ajaxed in when Vue is created.

clients.php

<input type="text" v-bind:value="customers[<? echo $this->client['id'];?>].name">

App data

var app = new Vue({
 el: '#app',
 data: {
    customers: {},
   }
})

app.js

created: function(){
  // fetches clients via AJAX and places them in customer object
    this.get_clients()
}

console error: TypeError: Cannot read property 'name' of undefined

1 Answer 1

1

Well well well.. seems like i cracked it......

I have set a value: clients_loaded: false.

When ajax is succeded i set it to true.

In my .php file i can then do:

<template v-if="clients_loaded"> // do stuff </template>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.