[Vuejs]-Pagination in Vue js & Laravel loses track of page after submitting form

0👍

Assuming that your form fields are using v-model or similar bindings with vue (as they should so you can leverage from Vue’s features), you can remove the @submit event on the form html tag and let vue handle the click event on the button.

<form>
    <input type="text" v-model="user.firtName"/>
    ... (generic form code)
    <button v-show="editmode" type="button" class="btn btn-success" @click="editmode ? updateUser() : createUser()">update</button>
</form>

Note that the type is now button instead of submit. After the updateUser or createUser are done doing their thing, just emit an event from the modal to the parent component to dismiss the modal.

updateUser(){
    this.$Progress.start()
    // Use Axios HERE, something like
    axios.put(base_path+'/admin_api/user/'+this.form.id, this.user)
        .then(()=>{
            // ...
        })
        .catch(()=>{
            this.$Progress.fail()
        })
        .finally(() => {
            this.$emit('closeModal');
        })
}

Leave a comment