1
<div class="recipe-ingredients__container__functions paddings">
    <h5>Functions_</h5>
    <div class="foo" v-for="f in content.functions"></div>
</div>

When Vue render this html the Ajax call is still in progress so content.functions is not available. After call is complete I can see with Vue Devtools(chrome) that data has been correctly added. Is there a easy way to force Vue to execute again the v-for directive as soon as content.functions becomes available?

1 Answer 1

3

Simply set your original data to an empty array then update it when the AJAX call completes.

For example

data () {
  return {
    content: {
      functions: []
    }
  }
},
created () {
  makeAjaxRequest().then(data => {
    this.content.functions = data
  })
}
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.