Adding to filament
ap1969 opened this issue · 2 comments
ap1969 commented
Hi Ryan,
Hope you don't mind me asking this hear. I'm trying to add this to filament, as follows:
JS source file (based off https://discord.com/channels/883083792112300104/883085267383226478/1013182668210446448)
console.log("Adding listener for clipboard");
document.addEventListener("alpine:initializing", () => {
Clipboard(Alpine);
console.log("Importing clipboard");
});
This gets converted from ES6 using laravel mix, then included in my serviceprovider via
Filament::serving(function () {
// Just import the local app.js for the filament base
// Ensure that mix is used to merge any relevant code into that app.js
// There is another app.js imported by Filament itself
Filament::registerScripts([
asset('js/clipboard.js')
]);
...
}
The "Adding listener for clipboard" is logged, but not the "Importing clipboard", so the plugin is never imported. And I'm not entirely sure the plugin install is correct, as you're using Alpine.plugin(Clipboard).
Any ideas how I can this working in Filament?
Regards,
Andy
ryangjchandler commented
Have you tried setting shouldBeLoadedBeforeCoreScripts
to true
, i.e.:
Filament::registerScripts([
asset('js/clipboard.js')
], shouldBeLoadedBeforeCoreScripts: true)
ap1969 commented
Ryan, you da man!
Thanks mate.