This repository was archived by the owner on Mar 18, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
resources/views/components/files Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -145,3 +145,17 @@ the `file-pond` component adds a watcher on your `wire:model` by using `@entangl
145145will pick up on those changes and remove the removed files from the FilePond instance.
146146
147147You can opt out of this behavior by setting the boolean attribute ` watch-value ` to ` false ` on the component.
148+
149+ ## Clear Event Listener
150+
151+ You may encounter some edge cases where you may need to clear the files out of the FilePond instance
152+ yourself. When using livewire, this can easily be accomplished by adding the following inside your
153+ component somewhere:
154+
155+ ``` php
156+ $this->dispatchBrowserEvent('file-pond-clear', ['id' => $this->id]);
157+ ```
158+
159+ Each Livewire component has its own unique id assigned to it, so by passing ` $this->id ` into the
160+ event you're emitting, the component will be able to match the ids and clear the files for the correct
161+ component.
Original file line number Diff line number Diff line change 11<div wire:ignore
22 x-data =" { pond: null, @if ($shouldWatch ($attributes ) ) value: @entangle ($attributes -> wire (' model' ) ), oldValue: undefined @endif }"
33 x-cloak
4+ x-on:file-pond-clear.window ="
5+ const id = $wire && $wire.__instance.id;
6+ const sentId = $event.detail.id;
7+ if (id && (sentId !== id)) {
8+ return;
9+ }
10+ @if ($multiple )
11+ pond.getFiles().forEach(file => pond.removeFile(file.id));
12+ @else
13+ pond.removeFile();
14+ @endif
15+ "
416 x-init ="
517 {{ $plugins ?? ' ' } }
618
3244
3345 this.oldValue = value;
3446 @else
35- ! value && pond.removeFile()
47+ ! value && pond.removeFile();
3648 @endif
3749 });
3850 @endif
You can’t perform that action at this time.
0 commit comments