This episode is for members only

Sign up to access "Modals in Inertia" right now.

Get started
Already a member? Sign in to continue
Playing
10. Modal flow examples

Transcript

00:00
So another kind of obvious thing that I think we should still cover is opening
00:04
modals from different locations where they kind of don't belong and also opening modals from within other modals. Now all of this is pretty straightforward we just link to modals that's all we really need to do it's kind of like linking to a different page but let's take a look at this again so we're
00:20
completely clear. Okay so the first thing I want to do is change this open modal to open up the new note modal so let's say that we had a shortcut somewhere in our app that allowed us to quickly create a note. How would we do that? Well if we head over to our dashboard all we're gonna do is hook this up to that
00:37
new modal. Now this isn't going to redirect us over to the notes index page despite that having a base path it is just going to show the modal so let's take a look. So we're gonna say notes.create and let's go over here and try this out. So as you can see although we've defined the base route for this as
00:56
the notes index page it doesn't redirect us over to the notes index page what it does do is if we re-hit this page we end up on the notes index page so that's what that base route is doing but from here we can just do what we would expect so this is like a quick create note action I can create a new note in here
01:15
hit create note and of course that's just going to redirect me back over to the notes page because that's what happens in our controller. So this is what I like about this we can just be really flexible as to where we're calling these modals and it just works really nicely. Now of course another
01:30
thing that we could do is link to another modal from within a modal so let's set this back to our modals example just here and we get the close button but inside of our example modal if we wanted to link off to a new modal we could do that very easily so let's bring in our link just here and we can
01:50
go and link over to create a new note for example so let's set this to go through to the notes create route and we'll just say create note of course this is looking a little bit odd but that's fine and we'll of course just make sure we import link from Inertia Vue 3. Okay let's go over open this
02:11
modal click create note that shows us the new modal we can enter something and of course we're redirected back over to this page so there we go a couple of flow things and opening modals within modals and it just works how we would expect
10 episodes 46 mins

Overview

Effortlessly add modals to your Inertia applications with the momentum-modal package.

In this course, we’ll get modals set up, design a customisable modal container with transitions, then cover everything you need to know about working with modals in your Inertia applications.

Alex Garrett-Smith
Alex Garrett-Smith
Hey, I'm the founder of Codecourse!

Episode discussion

No comments, yet. Be the first!