In livewire 2 I used method window.livewire.find when I needed to get access to elements in JS code, like :
<script>
// import { setAppTitle } from 'app';
function adminAppImageComponent() {
return {
getSubmitLabel: function () {
const doc = document.getElementById("app_image_admin_page_container"); // ref to container div
console.log('doc::')
console.log(doc)
var wireIds = window.livewire.find(doc.getAttribute("wire:id"))
console.log('wireIds::')
console.log(wireIds)
if (wireIds.get('updateMode') == 'edit') {
return "Update"
}
if (wireIds.get('updateMode') == 'add') {
return "Add"
}
},
It worked for me and I had dynamic text of label.
But in livewire 2 I got error on the same code :
https://img001.prntscr.com/file/img001/1l7ST_SyTPS-VXolG4Jjvg.png
Readiing docs at https://livewire.laravel.com/docs/upgrading I did not find any hints how can I do it ?
"laravel/framework": "^10.43.0",
"livewire/livewire": "^3.4"
Thanks in advance!