Opening modal from a custom page
Is it possible to open a modal from a class that extends Page?
$this->dispatch doesn't seem to be working, I want the modal to automatically open at the end of my submit function
Solution:Jump to solution
check properties https://livewire.laravel.com/docs/properties
Laravel
Properties | Laravel
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
21 Replies
Bump
possible, but we need to check some code that you are trying
So where I dispatch('reload')
I want to add a way to open my modal straight away, and this is my blade
Removed some h and p tags to hit character limit
what is
reload
?I defined that to just reload the page as the redirect back wasn't live refreshing, so when I have conditional buttons, they wouldn't display without the reload
I tried the modal opening without that reload there to no avail
would you like to open this modal?
<x-filament::modal id="view-qr-code">
$this->dispatch('open-modal', id: 'view-qr-code')
?Yeah
I tried that but it wasn't opening.
Could you try only this, just to see if it is working?
Sure, gimme half an hour, just travelling to the office
Yeah, that opens.
If I re-add my original code, it works without the reload dispatch, but my original blade fails, so could be something to do with it having if blocks etc?
try to move
@if ($this->userAuthenticatorEnabled())
to the modal button View Authenticator QR Code
Yeah updated it to this
But I think parts still wont work because its waiting for a page refresh to make note of the changes?
When I press submit, the button and qr code wont show until I refresh the page
page refresh? Shouldn't it be a livewire request?
Maybe im missing something then?
My class is defined like this, if this is any use:
if I add the if also into my submit button like this, it seems to work in reverse, so toggle on, nothing, but toggle off, it displays.
So Ill have to check the logic on my function there, but the button loads after a page refresh, when the authenticator method is enabled, so I believe the check is correct?
the submit button should send a livewire request, not page refresh.. as my example
Ah nah I mean, when I physically refresh the page after the submit process has finished
why are you refreshing the page?
Because the buttons aren't displaying initially
you can control this using livewire instead of refreshing the page
I havent had much exposure to livewire fully, what would I search in the docs to get what I need?
Solution
check properties https://livewire.laravel.com/docs/properties
Laravel
Properties | Laravel
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
Cheers, Ill take a look over and try a few things, thanks for the support so far
Yeah that works now, all I needed was to update my properties, so after I enable them against the user, I just had to update $this->methods.
Thanks again 🙂