Giter Club home page Giter Club logo

Comments (4)

jechazelle avatar jechazelle commented on July 17, 2024

Someone here seems to have this problem too https://laracasts.com/discuss/channels/filament/filament-custom-rich-editor-javascript-not-loading-in-modal-relation-manager?page=1&replyId=935999

I found the problem again, but not a solution.

a little help would be appreciated πŸ™‚

from filament.

BatthewZ avatar BatthewZ commented on July 17, 2024

Would it help to use AlpineJS for initialisation? I had some load issues,possibly due to server-side rendering with JS in a livewire component/blade template. I ended up fixing it with something like:

<div x-data="my_component">
  <!-- All of your component stuff in here -->
</div>

@script 
Alpine.data("my_component", () => {
    return {
    
        init() {
          //  All of your logic in here, sans the window.addEventListener wrapper
        }
    }
}
@endscript 

My understanding is that Alpine.js calls the 'init()' function after the related div with the x-data is rendered on the browser, so I think it might make everything happen in the right order. Please let me know if I'm wrong...

from filament.

danharrin avatar danharrin commented on July 17, 2024

I don't think @assets is a thing that we have added support for? Have you tried the Livewire @script directive as above?

Also, I would really appreciate it if you did not open more issues for questions about building custom fields, these aren't Filament bugs and belong in Discussions or Discord. If you do find a Filament bug then of course an issue is fine

from filament.

jechazelle avatar jechazelle commented on July 17, 2024

@BatthewZ thx for this way, the JS is execute but I have always the same problem : I get only one ID on two fields from modal. I would like to execute the JS on each custom field. But in my console.log, I have only the same last ID...

@danharrin I understand, I thought it was a bug because on a resource it's perfect, on modal I can get ID on each custom field. I tried @assets because I search a way to execute the JS on each field from modal... :-)

Modal:

MentionsRichEditor::make('one_sentence')
    ->id('one_sentence')
    ->mentionsItems($form)
    ->fileAttachmentsDisk('media')
    ->label('One sentence'),

MentionsRichEditor::make('description')
    ->id('description')
    ->mentionsItems($form)
    ->fileAttachmentsDisk('media')
    ->label('Description'),

View:


<div x-data="my_component">
    @include('filament-forms::components.rich-editor')
</div>
    
@assets
<script src="{{ url('js/libs/Tribute/Tribute.min.js') }}"></script>

<link href="{{ url('css/libs/Tribute/Tribute.min.css') }}" rel="stylesheet">
@endassets

@script
<script>
    Alpine.data("my_component", () => {
        return {

            init() {
                //  All of your logic in here, sans the window.addEventListener wrapper
                const id = '{{ $getId() }}';

                console.log(id);
            }
        }
    });
</script>
@endscript

Console.log:
Capture d’écran 2024-05-14 aΜ€ 15 08 20

from filament.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.