Inertia: Inertia link wont go to next component

Created on 9 Dec 2020  Â·  2Comments  Â·  Source: inertiajs/inertia

Hello i am wondering how can i go to my next component. Here is my code it doesn't work. I am using vuex and axios thanks

image

Most helpful comment

I think @click.prevent is going to prevent the button event from bubbling up to the inertia-link component, so the visit handler doesn't get fired.

What does createPatientProfile do? Based on this small snippet, I think you want something like this:

<template>
  <button class="btn-indigo" type="button" @click="createPatientProfile(formPatient)">
    Submit
  </button>
</template>
<script>
export default {
  // …

  methods: {
    createPatientProfile(data) {
      this.$inertia.post('/patients', data, { preserveState: true })
    }
  }
}
</script>

The /patients POST endpoint then needs to return a redirect to /partients/card-info.

Does that help? If it doesn't, please provide as much context as possible of what you're trying to achieve (routes, controllers, full components, etc.)

All 2 comments

I think @click.prevent is going to prevent the button event from bubbling up to the inertia-link component, so the visit handler doesn't get fired.

What does createPatientProfile do? Based on this small snippet, I think you want something like this:

<template>
  <button class="btn-indigo" type="button" @click="createPatientProfile(formPatient)">
    Submit
  </button>
</template>
<script>
export default {
  // …

  methods: {
    createPatientProfile(data) {
      this.$inertia.post('/patients', data, { preserveState: true })
    }
  }
}
</script>

The /patients POST endpoint then needs to return a redirect to /partients/card-info.

Does that help? If it doesn't, please provide as much context as possible of what you're trying to achieve (routes, controllers, full components, etc.)

@sebastiandedeyne thank you! This is what I'm exactly looking for.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ninjaparade picture ninjaparade  Â·  4Comments

MichaelDeBoey picture MichaelDeBoey  Â·  4Comments

reinink picture reinink  Â·  3Comments

sebastiandedeyne picture sebastiandedeyne  Â·  6Comments

reinink picture reinink  Â·  5Comments