Skip to content

Opening Modal Failed #381

Description

@mbs047

Hi there,

i planned to imploment spotlight to my project all day today, and in the process of implomenting i noticed an issue, it could be from my side, or the package side, as there is no error messages in the console. "Its clearer than my life xD"

however, i was trying to open a modal "Livewire-modal-element" using the following:

  public function execute(Spotlight $spotlight, Category $category)
    {
        $spotlight->dispatch('openModal')->to(CategoryModal::class);
    }

but nothing get open or closed, but when i use the old school method using a button that has a $dispatch, it wors just fine.

any idea in how to fix it?

Additional, here is my modal component

<?php

namespace App\Livewire\Dashboard\Catalog\Category;

use App\Livewire\Forms\Dashboard\Catalog\CategoryForm;
use App\Models\Catalog\Category;
use Jantinnerezo\LivewireAlert\LivewireAlert;
use Livewire\WithFileUploads;
use LivewireUI\Modal\ModalComponent;

class CategoryModal extends ModalComponent
{
    use LivewireAlert, WithFileUploads;

    public ?Category $category = null;
    public CategoryForm $form;

    public $categories = [];

    public function mount(Category $category = null): void
    {
        if ($category->exists) {
            $this->form->setCategory($category);
        }

        $this->categories = Category::whereNull('parent_id')->get();
    }

    public function save()
    {
        $response = $this->form->save();

        $this->closeModal();

        $this->dispatch('refresh')->to(CategoryComponent::class);

        $this->alert('success', $response ?? 'undefined');
    }

    public function render()
    {
        return view('livewire.dashboard.catalog.category.category-modal');
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions