Implement js library in custom widget
I have an app running on Inertia/Vue that I'm considering switching to Filament. My only hangup right now is that this app uses fullcalendar.io and specifically I need to render custom content for the event. I am aware of the fullcalendar plugin and have asked this question on that plugin's server but haven't gotten a response (https://discord.com/channels/883083792112300104/935819320699805737/1133498041144463411)
What I am wondering is if there is any way in Filament/Livewire/Alpine to make use of the content injection functionality offered by fullcalendar (https://fullcalendar.io/docs/content-injection). Using the Vue fullcalendar library, this is trivial because I can simply return a Vue component to the eventContent function since, in the background, fullcalendar is using VDOM (preact).
I realized I can create this HTML in a string in javascript and use the "arg" parameter that provides the calendar event for dynamic content but I am looking for a more elegant way to do this.
Trying to do this in Filament may not be a good fit but want to get some advice before writing off Filament for this project. Thanks
Solution:Jump to solution
Okay so I have something like this:
Widget.php
```php
use Filament\Widgets\Widget;...
6 Replies
Hey ! π
I've already build a custom Page using Fullcalendar.
With the help of Livewire, you can easily make what you ask for π
The implementation is trivial too, since you can load external Scripts or CSS using something like this:
More documentation:
https://filamentphp.com/docs/3.x/support/assets#registering-css-files
https://filamentphp.com/docs/3.x/support/assets#registering-javascript-files
Using a compiled version of Fullcalendar (if you use the node version of it) is possible too, simply load you app.js compiled with Vite or anything else.
After that you have the full power to use the native interaction between PHP and Javascript with Livewire
Thanks @jibaymcs for your response. Yes Iβve reviewed the documentation and have fullcalendar working in a widget using FilamentAsset but specifically what Iβm asking is if I can use the βargβ parameter passed to the fullcalendar eventContent function and return dynamic HTML. Do you use the fullcalendar eventContent function in your custom widget?
Oh, okay, let me check if I have a sample code for you
Solution
Okay so I have something like this:
Widget.php
resources/views/filament/widgets/full-calendar-test.blade.php
It's not a perfect solution I think, but you have something works π
Blade injection works too.
resources/views/test-content-injection.blade.php
Hope you can work with this little tricks !
Okay so you are including the html in the extended props - I like this idea and will give it a try. Thanks