Skip to content

Commit

Permalink
fix: Ensure correct UUID is dispatched when using multiple dropzone c…
Browse files Browse the repository at this point in the history
…omponents on the same page (#32)
  • Loading branch information
dasundev authored Apr 27, 2024
2 parents 378ec90 + 89e8bb3 commit 8f54b02
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions resources/views/livewire/dropzone.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
x-cloak
x-data="dropzone({
_this: @this,
multiple: @js($multiple)
uuid: @js($uuid)
multiple: @js($multiple),
})"
@dragenter.prevent.document="onDragenter($event)"
@dragleave.prevent="onDragleave($event)"
Expand Down Expand Up @@ -117,7 +118,7 @@ class="dz-hidden"

@script
<script>
Alpine.data('dropzone', ({ _this, multiple }) => {
Alpine.data('dropzone', ({ _this, multiple, uuid }) => {
return ({
isDragging: false,
isDropped: false,
Expand Down Expand Up @@ -154,10 +155,10 @@ class="dz-hidden"
},
removeUpload(tmpFilename) {
// Dispatch an event to remove the temporarily uploaded file
_this.dispatch('{{ $uuid }}:fileRemoved', { tmpFilename })
_this.dispatch(uuid + ':fileRemoved', { tmpFilename })
},
});
})
</script>
@endscript
</div>
</div>

0 comments on commit 8f54b02

Please sign in to comment.