F
Filament12mo 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
LeandroFerreira12mo 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
AbiOP12mo 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
LeandroFerreira12mo ago
are you using v3? Where are you trying to use this action?
Abi
AbiOP12mo ago
Upgraded to v3 and works fine, but had to use the livewire object
Want results from more Discord servers?
Add your server