3
votes

I'm developing my first Nova field. It's an index field that contains a button which sends an Axios request, and when a response is being returned I need to reload the index view.

For now I got this:

this.$router.go(this.$router.currentRoute);

The problem is that it refreshes the entire page (a hard-refresh, like when you press Cmd+R). I just want to reload the current route (which is the index route of a resource).

I also tried this:

            this.$router.push({
                name: 'index',
                params: {
                    resourceName: this.resourceName,
                },
            });

But since I pushed the same route, it does nothing.

Any ideas?

Thank's, Daniel.

1
why you need to refresh the page? try to bind the content to a given data object propertyBoussadjra Brahim
I am also looking for a similar solution. Did you ever find anything better than reloading the page? I see that the component receives a "changed" event when deleting a row in an index. So I am wondering how we can trigger that event to a specific component programmatically.Michael Pawlowsky

1 Answers

1
votes

You can try something like this

let currentFilters = _.cloneDeep(this.$store.state[`${this.resourceName}`]['filters']);
await this.$store.commit(`${this.resourceName}/storeFilters`, {});
await this.$store.commit(`${this.resourceName}/storeFilters`, currentFilters);

This code will reset currently applied filters to empty object and then requests old filters again which leads to resource index updating. But be careful - this method makes two requests to the server.

I'm facing the same issue now while trying to implement custom popup component - but that's all I could do with implemented in Nova vuex store.

Idea of implementation was taken from https://github.com/tanmuhittin/nova-reload-resources/blob/f27da9507a97696b7aca0e9bd7e5afd3001f0891/resources/js/components/Card.vue#L21