Jul 19, 2023
0
Level 4
State refresh after create in inertia and vue
I have a form when I am done with the creation and redirect back to home, the post on the home page does not reflect the recent post till I manually refresh the page.
here is the code for the form
const handleSubmit = () => { form.post(route('post.store'), { onSuccess: () => { toggleShow() form.reset() }, only: ['title', 'body'] } ) }
<Modal :show="show" @close="toggleShow" max-width="lg" :title="isQuestion ? 'Ask Question' : 'Create Post' ">
<form @submit.prevent="handleSubmit">
<input v-if="isQuestion" type="text"
v-model="form.title"
placeholder="What is your question?"
class="w-full border-b-2 border-gray-600 ring-gray-700 border-0 outline-0 p-2
resize-none focus:outline-none
outline-none focus:ring-0 placeholder-gray-800">
<InputError :message="form.errors.title" class="mt-2"/>
<textarea name=""
v-model="form.body"
:placeholder="isQuestion ? 'Describe your question' : 'What is on your mind?'"
class="w-full border-0 outline-0 p-2 h-[300px]
resize-none focus:outline-none mt-2
outline-none focus:ring-0 placeholder-gray-800"></textarea>
<InputError :message="form.errors.body" class="mt-2"/>
<div class="mt-2 flex justify-between items-start">
<Button color="dark" type="submit">
Share
</Button>
</div>
</form>
</Modal>
please what is the solution
Please or to participate in this conversation.