Draggable CRUD not working inside modal action
mkrecek234 opened this issue · 1 comments
mkrecek234 commented
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.