How to make a CRUD edit modal, that receive the content from a list?

Viewed 15

I'm iniciant in NUXT/vue and I'm not being sucessful in this task. There is a list of register people and we need to call a modal to do de edition. There is the separation in components:

  • Component Modal to edit
  • Component of List with the component Modal
  • Page with the component List
/*I was doing this on the List component*/
 showEditar(itemOrdem) {
      this.editar = true;
      if (this.editar === true) {
        this.id = itemOrdem.id;
        this.$router.push(`/ordem-de-servicos/?ordem=${itemOrdem.id}`);
        this.$nuxt.refresh();
        this.$nextTick(function () {
          this.$bvModal.show(`criar-${this.editar}-${this.id}`);
        });
        this.ordem_selecionada = itemOrdem;
      }
    }, 

/* in the Edit component */

 async mounted() {
  await this.teste();
}
async teste() {
      if (this.$route.query.ordem) {
        const id = this.$route.query.ordem;
        const taskID = await this.$axios.$get(
          `tasks/${id}`,
          this.$data.formData,
        );
        this.formData = taskID;
      }
    },
0 Answers
Related