When using the Tabs layout in custom page, how can I make an action react to tab changes?
I have a form with a tab layout, with 3 tabs and 3 action buttons.
Now I want to make sure that only one action shows for each tab.
This is my Tabs layout schema:
Where I attempted to fetch the current tab from the url parameter and hide my actions conditionally like this:
This only works on page load, but not when I change the tabs dynamically. How can I make this work when switching tabs dynamically?
9 Replies
bump
Curious, can you not just use
$this->activeTab
?No because it's not the same tabs, unless I am mistaken. The activeTab is set by the getTabs() method, not by the Tab layout
You can probably inject $livewire in the hidden() callback and check the active tab directly off the livewire component.
You mean adding $livewire directly to the hidden() callback like this:
The log output gives me this:
I couldn't find anything about the tab info, should I use $livewire differently?
I don't know if it changes anything, but I am doing this in a custom page
class ManageSettingsNew extends Page
Well, yea. That’s kinda what I was getting at, but in a custom page the tabs are probably not tied to the page which is the livewire component.
But the url parameters still update, is there no way to tap into that and react to the change from my custom page? Or do I have to write my own blade view for this?
If it’s in the query, livewire should still have knowledge of it. Check the livewire docs for reading the query string.
I can't seem to get it to work with the query parameters :/
I think I might have to use
->persistTab()
instead of ->persistTabInQueryString()
, as it seems this would store the tab in memory. I am just trying to figure out how to tab into this as well.