问题
I want to add a specific js file to a page of specific entity crud. (example: I want to add Tag-insert.js
to the insert page of Tag
crud)
Is there any way to do this?
回答1:
You could use a widget to insert custom javascript in the crud page.
Check out the docs for widgets. Focus on after_scripts section.
Example:
you can create fooCrud.blade.php
in resources/views/vendor/backpack/base/widgets
that the blade file contains your custom javascript like this:
@push('after_scripts')
<script src="{{ asset('packages/backpack/crud/js/foo/foo-crud.js') }}"></script>
@endpush
then you can add this widget on your desire page, like this:
Add the following code to desire setupCreateOperation()
function in specific CRUD controller:
$this->data['widgets']['after_content'] = [
[
'type' => 'fooCrud' // name of widget
]
];
来源:https://stackoverflow.com/questions/60969475/how-to-add-custom-js-file-to-each-page-of-specific-entity-crud-in-laravel-backpa