From the course: Vue.js 2 for Web Designers

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Updating message list after posting

Updating message list after posting - Vue.js Tutorial

From the course: Vue.js 2 for Web Designers

Start my 1-month free trial

Updating message list after posting

- [Narrarator] Now we have a status updater that can read messages from our little API and post new ones. But to see them we have to reload the page. In this video we will fix that problem with another custom event. Our form component needs to notify the rest of the view instance that a message has successfully posted. And we need to act on that information somehow. We will set up the event first, and act on it afterwards. Over here in hotel.js I am going to scroll down to my post status form component here. And this is where the message has been received by the API and we need to make sure that it updates. So down here I am going to emit using this.$emit some event; I'll call it add-message. And along with that event I will pass in the new status. That way when this event fires we will have the data that we want to stick onto the message list right there. Now we need to handle this event somehow. We will do that in index.html I'm going to jump down to line 50 with control G. Here is…

Contents