How to include external js in the filament render hook?

I’ve created a Filament render hook and passed a Livewire component inside it. Now, I want to implement drag-and-drop functionality for the table rows in the Livewire component. I’m using livewire-sortable.js for this, but it’s not working as expected. Could someone guide me on the correct placement of the livewire-sortable.js CDN to avoid unexpected errors, loading issues, or UI problems in Filament?
<?php
//AppServiceProvider.php
public function boot(): void
{
FilamentView::registerRenderHook(
PanelsRenderHook::GLOBAL_SEARCH_AFTER,
fn (): string => Blade::render('@livewire(\'products.product-cart\')')
);
}
?>
<?php
//AppServiceProvider.php
public function boot(): void
{
FilamentView::registerRenderHook(
PanelsRenderHook::GLOBAL_SEARCH_AFTER,
fn (): string => Blade::render('@livewire(\'products.product-cart\')')
);
}
?>
<?php
//product-cart.blade.php
<div>
//code here
</div>
@livewireScripts
<script src="https://cdn.jsdelivr.net/gh/livewire/[email protected]/dist/livewire-sortable.js" defer></script>

?>
<?php
//product-cart.blade.php
<div>
//code here
</div>
@livewireScripts
<script src="https://cdn.jsdelivr.net/gh/livewire/[email protected]/dist/livewire-sortable.js" defer></script>

?>
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?