Replies: 1 comment
-
For anyone else who comes across this; This is the method I have come up with to auto-save on upload: use WithMedia;
public $mediaComponentNames = ['media'];
public $media;
protected $rules = [
'media' => 'nullable',
];
protected $listeners = [
'saveMedia',
];
public function saveMedia()
{
$this->purchaseOrder
->syncFromMediaLibraryRequest($this->media)
->toMediaCollection('po-media');
} <x-media-library-collection :model="$purchaseOrder" name="media" collection="po-media"/>
<script>
document.addEventListener("DOMContentLoaded", () => {
Livewire.hook('message.processed', (message, component) => {
if (message.updateQueue[0].payload.event === 'media:mediaChanged')
Livewire.emit('saveMedia');
})
});
</script> |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello
Is it possible to get Media Library Pro Collection (Livewire 3 MLP v11) to automatically save on upload instead of having to click the Submit/Save button?
I have managed to get it working by writing a JavaScript Livewire hook for the "mediaChanged" event, but it only works part of the time.
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions