wire:navigate on an Action
Sounds simple, but an action can redirect to a URL like so:
And it works great. But can I put
wire:navigate
on that URL?6 Replies
->extraAttributes([‘wire:navigate’ => ‘true’])
Maybe
@awcodes I tried it, and it had interesting and unexpected behavior.
Here, it actually worked fine:
But on something like this, it immediately went to a 404:
I have noticed similar 404 behavior if you put "wire:navigate" accidentally on anything that isn't an <a> tag. For example, I've accidentally put it on a <div> containing an <a> tag and it happens. So it's likely a misplaced
wire:navigate
.it could be that extraAttributes on a Column are getting applied to the wrong element, as you say.
would have to look at the HTML to see where it's getting placed.
Good morning guys - I have the same problem: Added a table to an livewire component, want to
but the extraAttribute will placed to the div like so:
are there any possibilities to add the wire:navigate directly to the a tag?
I'm having the same problem!
@d3v1anX Did you make any progress?
for tables I had to do it via js
TextColumn::make('organization.full_name')
->label('Organization Name')
->formatStateUsing(function (Document $record) {
$url = route('organizations.show', ['organization' => $record->organization->slug]);
return "<a href="$url" class="dynamic-link text-blue-500 hover:underline">{$record->organization->full_name}</a>";
})
->html();
document.addEventListener('livewire:navigated', () => {
document.querySelectorAll('a.dynamic-link').forEach((link) => {
link.setAttribute('wire:navigate', '');
});
});