F
Filament5mo ago
Abi

Open a URL in a new tab after Custom Action in a Panel

I have the following action defined on a Resource's View Page and I want to store the data and open a URL in a new tab. What is the cleanest way to do this inside a Filament Panel
Actions\Action::make('Create Campaign')
->form([
TextInput::make('name')
->label('Campaign Name'),
Select::make('Audience')
->options([
'customers' => 'Event Customers',
'others' => 'Everybody except Event Customers'
])
])
->action(function ($data) {
// Store the data and open a URL in a new tab
})
Actions\Action::make('Create Campaign')
->form([
TextInput::make('name')
->label('Campaign Name'),
Select::make('Audience')
->options([
'customers' => 'Event Customers',
'others' => 'Everybody except Event Customers'
])
])
->action(function ($data) {
// Store the data and open a URL in a new tab
})
4 Replies
LeandroFerreira
LeandroFerreira5mo ago
->action(function (array $data) {

//store the $data..

$url = 'https://xxx.com';
$this->js("window.open('$url', '_blank').focus();");
})
->action(function (array $data) {

//store the $data..

$url = 'https://xxx.com';
$this->js("window.open('$url', '_blank').focus();");
})
Abi
Abi5mo ago
Thank you, let me try this. @Leonardo Ferreira is the js method on the $this object? can't seem to resolve it. get the error ::js does not exist. should it be $livewire->js? tried the $livewire object as well and same error
LeandroFerreira
LeandroFerreira5mo ago
are you using v3? Where are you trying to use this action?
Abi
Abi5mo ago
Upgraded to v3 and works fine, but had to use the livewire object