How to add custom js file to each page of specific entity CRUD in laravel-backpack

大兔子大兔子 提交于 2021-01-07 02:27:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!