Re-render FileUpload Component
I have a scenario where I have a select component with a few options, when a user selects an option from the select component I'm conditionally showing and updating the FileUpload component. IE. to use the circleCropper or not, dimensions of the image being cropped etc. However, when I change my selection I have no way of rerendering the FileUpload component in order for it to render with the updated dimensions, etc. from the selection they chose.
Is there a way to re-render a component or update its state?
Solution:Jump to solution
the only idea i have is something like
->extraFieldWrapperAttributes(fn ($get) => ['wire:key' => $get('shop_product_id') . '-file-upload'])
9 Replies
You need
live()
and closure customizationThanks @Dennis Koch , for more context this is what I have currently.
Hm. Might not work because FilePond is not reinitialized. I don’t have an idea sorry.
Hmm, ok thanks for looking into it. Been working on it for days...
@Dan Harrin , do you have any ideas on how I can re-render or update the state the FileUpload component when the shop_product_id changes?
Solution
the only idea i have is something like
->extraFieldWrapperAttributes(fn ($get) => ['wire:key' => $get('shop_product_id') . '-file-upload'])
@Dan Harrin , I was able to use
->extraAttributes(fn($get) => ['wire:key' => $get('shop_product_id') . '-file-upload'])
and that was exactly what I needed. Thanks a ton on this suggestion!do you need it explaining how it works or do you get it
I found a write up on it in the docs, all set.
How to do the same with @MohamedSabil83 tiny-editor plugin.
TinyEditor::make('description')
->required()
->columnSpanFull()
->label('Description')
->extraAttributes(fn ($get) => ['wire:key' => $get('gender') . '-description'])
,
I tried the same, it's not working as expected. Please help.