F
Filament16mo ago
ILPAV

Using url() on BulkAction

Hello, I am trying to find a way to open multiple external urls that download files with BulkAction. Using url() I do not understand how to get the selected items and with action() I tried to redirect to the external link for each record but only the last one is downloaded. Do someone have an idea on how to achieve this? Thanks
7 Replies
LeandroFerreira
LeandroFerreira16mo ago
Why not a .zip file?
ILPAV
ILPAVOP16mo ago
Because all the files are in a different server, so I just want a way to open all the selected record links in a new tab
toeknee
toeknee16mo ago
I don't think you'll find a solution to do that since a reponse is usually given from a requrest, but you want a request to give multiple responses. You'll likely need some custom js to handle that from a json response or similar. Really you should download a zip, pulling in the files.
ILPAV
ILPAVOP16mo ago
Thank you for the tip! I don't understand why but window.open doesn't work for me while alert yes:
->action(function (ListModels $livewire, Collection $records) {
$records->each(function (Model $record) use ($livewire) {
$livewire->js("alert('$record->link')"); // ok
$livewire->js("window.open('$record->link', '_blank')"); // does nothing
});
}),
->action(function (ListModels $livewire, Collection $records) {
$records->each(function (Model $record) use ($livewire) {
$livewire->js("alert('$record->link')"); // ok
$livewire->js("window.open('$record->link', '_blank')"); // does nothing
});
}),
toeknee
toeknee16mo ago
Did you allow popups from the browser
ILPAV
ILPAVOP16mo ago
It was because of this thanks
Want results from more Discord servers?
Add your server