Skip to content

Commit

Permalink
add a functionality to reset FilePond instance (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nevercom authored Oct 7, 2024
1 parent 606eb08 commit aa37321
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions resources/views/upload.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ class="{{ $attributes->get('class') }}"
pond.on('addfile', (error, file) => {
if (error) console.log(error);
});
$wire.on('filepond-reset-{{ $wireModelAttribute }}', () => {
pond.removeFiles();
});
}"
>
<input type="file" x-ref="input">
Expand Down
6 changes: 6 additions & 0 deletions src/WithFilePond.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,10 @@ public function revert($property, $filename): void
return false;
});
}

public function resetFilePond(string $property): void
{
$this->reset($property);
$this->dispatch("filepond-reset-$property");
}
}

0 comments on commit aa37321

Please sign in to comment.