Skip to content

Draggable CRUD not working inside modal action #2126

Open
@mkrecek234

Description

@mkrecek234

I have a crud which itself has an addModalAction that opens a modal show a child model's crud. If I addDraggable to that child model's crud, it throws an error:

$crud = \Atk4\Erp\Crud::addTo($app);
$crud->setModel($model = new Model\TicketType($app->db));

$crud->addModalAction(['icon'=>'tags'], ['title' => 'Edit tags'], function ($v, $id) use ($crud, $model) {
    $entity = (clone $model)->load($id);
    $crud2 = \Atk4\Ui\Crud::addTo($v);
    $crud2->setModel($entity->ref('TicketTags'));

    $dragHandler = $crud2->addDragHandler();
        $dragHandler->onReorder(function ($order) use ($model){

            $model->atomic(function () use ($model, $order) {
                foreach ($model as $entity) { $entity->save(['sort' => array_search($entity->id, $order)]); }
            });

           return new \Atk4\Ui\Js\JsToast('New sort order saved.');
        });


});

The error is API JavaScript Error Can't find variable: Draggable upon opening of the modal.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions