Using jquery within a blade in Filament
I want to be able to do some stuff that requires jquery. I have done the following:
- downloaded jquery and placed it in
- registered it in thus:
public function boot(): void
{
FilamentAsset::register([
Js::make('jquery', __DIR__ . '/../../resources/js/jquery-3.7.1.min.js'),
]);
}
- ran and can see that jquery.js is now present in public/app/js
I have this very simple blade content () :
<div>
<!-- Test Button to trigger jQuery -->
<button type="button" class="btn btn-primary" id="testButton">
jquery Button
</button>
</div>
<!-- jQuery Test Script -->
<script>
$(document).ready(function() {
$('#testButton').click(function() {
alert('jQuery is working!');
});
});
</script>
Q: is this valid within a blade? The blade is referenced by a custom column which is defined within my resource as
For clarity, I am seeing the button "jquery btn" displayed - just nothing happens when I click it. Oh and I have verified that jquery is being loaded (see image).
So... what obvious thing am I missing here..?
thx!
j0 Replies