mikebronner's avatar

How to display Laravel Nova save success message?

Using the following, it is easy to show an error message in Nova in Vue:

Nova.$emit('error', error.response);

However, using the anticipated success option doesn't do anything:

Nova.$emit('success', "Yay, it worked!");

What is the right way to do this? I'm looking to show that a save was successful. Thanks!

                Nova.request()
                    .put("/my/nova/route/" + this.parameter, data)
                    .then(function (response) {
                        Nova.$emit("success", "Yay, it worked!");
                    })
                    .catch(function (error) {
                        Nova.$emit('error', error.response);
                    });
0 likes
4 replies
mikebronner's avatar
mikebronner
OP
Best Answer
Level 16

I was able to figure it out:

                var self = this;
                Nova.request()
                    .put("/my/nova/route/" + this.parameter, data)
                    .then(function (response) {
                        self.$toasted.show("Yay, it worked!", {type: "success"});
                    })
                    .catch(function (error) {
                        self.$toasted.show(error.response, {type: "error"});
                    });
3 likes
jberculo's avatar

You can also do

Nova.success('Success message');

and

Nova.error('Error message');

You do not have to juggle with this and self, it is in scope either way

4 likes
vlab22's avatar

@jberculo more detailed.

Instead of

self.$toasted.show("Yay, it worked!", {type: "success"}); //didn't work in my Nova 3.0

Use:

Nova.success('Success message');

Inside the then function,

Worked in Nova 3.0

1 like

Please or to participate in this conversation.