I have two components:
<div>
<advertiser-add-component></advertiser-add-component>
<advertisers-component></advertisers-component>
</div>
These components have the following interface:
First component is a button. I will see a modal dialog when I click on it. The modal contains an Ajax form:
Second component is a table. You already saw it on the first picture So, I would like to rerender the table component after sending the form without page refreshing. Is there some way to "subscribe" to this event (once the modal information is sent) from advertisers-component? How I can organize it with minimum code?
Yes absolutely, for something like this you could spin up a simple event bus, your component would emit an update to the bus, and the other watches for updates to that event type on the bus.
Here's a good example of how to do it:
https://alligator.io/vuejs/global-event-bus/
Im using vue-events package: https://github.com/cklmercer/vue-events
Add events object in your component with the events to listen, and fire the event from the modal, check this example:
I would encourage you to check this: https://vuejs.org/v2/guide/state-management.html
Basically you have a component (or java class) called a store that holds the data of the table. That data is the one displayed by the table. When submitting the modal, you ask the store to fetch the data again (by sending an event) from your backend where I assume the data is stored.
Since the table displays the data of the store already, the table will update itself automatically.
I have done just that in an application of mine here: https://github.com/Draluy/Jobsearch/blob/master/front/src/components/applications/Application.vue
I have a question whether this is possible or not. For example, there is one code like below. But that code has an error for sure. And I want to make if is true when one data is at some array. Could ...
I have a question whether this is possible or not. For example, there is one code like below. But that code has an error for sure. And I want to make if is true when one data is at some array. Could ...
Firebase has a function 'createUserWithEmailAndPassword' that can be called from the frontend to create a user. What prevents someone from manually invoking the function from inside your javascript ...
Firebase has a function 'createUserWithEmailAndPassword' that can be called from the frontend to create a user. What prevents someone from manually invoking the function from inside your javascript ...
I want to get today's date + 7 days. Today I get with public dateToday: string = new Date().toLocaleDateString('de-DE'); On Google I found this: this.dateOneWeek.setDate(this.dateOneWeek.getDate() +...
I want to get today's date + 7 days. Today I get with public dateToday: string = new Date().toLocaleDateString('de-DE'); On Google I found this: this.dateOneWeek.setDate(this.dateOneWeek.getDate() +...
I have a weird issue with ngAnimate in a simple application I'm doing with the MEAN Stack. Both angular.js and angular-animate.js are 1.4.7 version. I have an ul that looks something like this: &...
I have a weird issue with ngAnimate in a simple application I'm doing with the MEAN Stack. Both angular.js and angular-animate.js are 1.4.7 version. I have an ul that looks something like this: &...