Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't pre-populate fields in edit forms #24

Open
dennisbrandenberger opened this issue Oct 19, 2017 · 2 comments
Open

Can't pre-populate fields in edit forms #24

dennisbrandenberger opened this issue Oct 19, 2017 · 2 comments

Comments

@dennisbrandenberger
Copy link

dennisbrandenberger commented Oct 19, 2017

I find it very difficult to populate a form with existing data derived from a query. in order to update the v-model connected variables in data(), I've tried to do this:

created () {
  this.description = this.Post.description
}

but it only works once in a while. (wrong timing)

I've also tried:

watchLoading (isLoading, countModifier) {
 if (!isLoading) {
  this.description = this.Post.description
 }
}

But that does not work either. Any suggestions ?

@dennisbrandenberger dennisbrandenberger changed the title How to populate an edit form ? Can't pre-populate fields in edit forms Oct 21, 2017
@dennisbrandenberger
Copy link
Author

dennisbrandenberger commented Oct 21, 2017

Found a solution. Now I'm doing this:

//.......
variables () {
  return {
    postId: this.$route.params.carId
  }
},
fetchPolicy: 'cache-and-network',
watchLoading (isLoading, countModifier) {
  if (!isLoading) {
    this.$nextTick(() => {
      this.description = this.Post.description
    })
  }
}

@dennisbrandenberger
Copy link
Author

Got som help from @Samuell1:
Use:

result ({ data, loading }) {
    if (!loading) {
      this.description = data.Post.description
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant