Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Livewire components that use scripts does not work #3

Open
craigvc opened this issue Mar 13, 2023 · 2 comments
Open

Adding Livewire components that use scripts does not work #3

craigvc opened this issue Mar 13, 2023 · 2 comments

Comments

@craigvc
Copy link

craigvc commented Mar 13, 2023

I made a slideover, and added a livewire component inside it (laravel comments with livewire
Slideover Code
<x-wire-elements-pro::bootstrap.slide-over :content-padding="false"> @livewire('tenant.modules.tasks.components.slide-over.task-detail-comments') </x-wire-elements-pro::bootstrap.slide-over>

Livewire Controller

`<?php

namespace App\Http\Livewire\Tenant\Modules\Tasks\Components\SlideOver;

use App\Models\Tenant\Task;
use Livewire\Component;

class TaskDetailComments extends Component
{
    public $task = 1;
    public function mount(Task $task)
    {
        $this->task = $task;
    }
    public function render()
    {
        return view('livewire.tenant.modules.tasks.components.slide-over.task-detail-comments');
    }
}`

Livewire blade

`<div>
    <x-comments::styles />
    @ray($task)
    Task Details {{ $task->id}}
    <livewire:comments :model="$task" />
    <x-comments::scripts />
</div>`

The issue comes with loading the <x-comments::scripts /> when used in a slideover component

Any ideas @PhiloNL

@PhiloNL
Copy link
Contributor

PhiloNL commented Mar 19, 2023

@craigvc can you try moving

<x-comments::styles />
<x-comments::scripts />

To your base layout file. These need to be part of the initial page load as they are not loaded when loading a modal / slideover.

@craigvc
Copy link
Author

craigvc commented Mar 20, 2023

@PhiloNL I tried that too, I also actually got it working by adding an actual comments componentn to the page that calls the modal - but only the by displaying an actual comment - <livewire:comments :model="$task" /> (just the script tags dont work on their own on the calling page) its not gonna be any good to me though as i dont need the comments on the calling page :) i just need it on the modal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants