关于Dcat-admin使用模态框会导致失效的问题

1. 运行环境

1). 当前使用的 Laravel 版本?

9.2

2). 当前使用的 php/php-fpm 版本?

PHP 版本:
8.1

3). 当前系统

docker php image

4). 业务环境

开发环境

5). Dcat-admin版本

2.*

2. 问题描述?

在列表中使用异步表格,异步表格中的批量操作没有反应

$grid->column('subject', '选择题试题')
 ->display('选择题试题')
 ->modal('选择题试题', \App\Admin\Renderable\ExamSubject::make());

modal中的代码

class ExamSubject extends LazyRenderable
{

    public function grid(): Grid
    {
        $choiceTypeMap = ChoiceQuestion::$choiceTypeMap;
        $categories = QuestionCategory::query()
            ->pluck('name', 'id')
            ->toArray();
        return Grid::make(new ChoiceQuestion(['questionCategory']), function (Grid $grid) use ($choiceTypeMap, $categories) {
            $grid->column('id', 'ID')->sortable();
            $grid->column('name');
            $grid->column('questionCategory.name', '题目分类');
            $grid->column('score', '分数');
            $grid->column('created_at');
            $grid->paginate(8);
            $grid->withBorder();
            $grid->batchActions([new BatchResetPassword()]);
            $grid->disableActions();
            $grid->addTableClass(['table-text-center']);
            $grid->filter(function (Grid\Filter $filter) use ($choiceTypeMap, $categories) {
                $filter->equal('choice_type', '选择题类型')->width(4)->select($choiceTypeMap);
                $filter->equal('category_id', '选择题类型')->width(4)->select($categories);
                $filter->like('name', '题目名称')->width(4);
            });
        });
    }
}

批量操作的代码

class BatchResetPassword extends BatchAction
{
    protected $title = '修改密码';

    public function render()
    {
        // 实例化表单类
        $form = ResetPasswordForm::make();

        return Modal::make()
            ->lg()
            ->title($this->title)
            ->body($form)
            // 因为此处使用了表单异步加载功能,所以一定要用 onLoad 方法
            // 如果是非异步方式加载表单,则需要改成 onShow 方法
            ->onLoad($this->getModalScript())
            ->button($this->title);
    }

    protected function getModalScript()
    {
        // 弹窗显示后往隐藏的id表单中写入批量选中的行ID
        return <<<JS
// 获取选中的ID数组
var key = {$this->getSelectedKeysScript()}

$('#reset-password-id').val(key);
JS;
    }
}

这是在列表的批量操作

这是在模态框里的操作

请问这是什么原因造成的?

《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
最佳答案

使用替代方案 文档地址
通过github 提 issue 得到暂时解决方案


    protected function script()
    {
        $script = <<<JS
(function () {
    $(".dropdown-toggle").on('click',function(){
        $(this).next().toggleClass('show');
    })
})();
JS;
        Admin::script($script);
    }
1年前 评论
讨论数量: 9

你要写相关代码呀, ExamSubject 怎么写的

2年前 评论
西巴以及 (楼主) 2年前

我也遇到这个问题了,楼主最后解决了没有?

2年前 评论
西巴以及 (楼主) 2年前

用MultipleSelectTable

2年前 评论

我在模态框里加导出按钮点击也没有反应, 楼主解决了吗?

1年前 评论
西巴以及 (楼主) 1年前
I_Ming 1年前

使用替代方案 文档地址
通过github 提 issue 得到暂时解决方案


    protected function script()
    {
        $script = <<<JS
(function () {
    $(".dropdown-toggle").on('click',function(){
        $(this).next().toggleClass('show');
    })
})();
JS;
        Admin::script($script);
    }
1年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!