Closed mkochstroer closed 2 years ago
Helped myself with the following workaround
onclick='Livewire.emit("openModal", "user-task", [{userid:{{$user->id}}}])'
and in the mount function:
public function mount($array) { $this->userid = $array["userid"]; }
I try to pass some parameters. But with the given example I got the js error "Uncaught (in promise) SyntaxError: missing } after property list"
And the modal dosn't open. - Without parameters it opens. Is there an error on my side?
My code
<script> document.getElementById("buttonName").onclick = function() { var data = {!! json_encode(["userid" => 1]) !!}; Livewire.emit("openModal", "user-task",data); } </script>
Tried it before with {{ json_encode(["userid" => 1])) }} and var data = '{!! json_encode(["userid" => 1]) !!}'; var data = '{{ json_encode(["userid" => 1]) }}'; but same issue.
laravel `class UserTask extends ModalComponent { public $userid;
}`
Stack `Uncaught (in promise) SyntaxError: missing } after property list initialize node_initializer.js:11 value index.js:92 value index.js:525 walk walk.js:5 walk walk.js:10 walk walk.js:10 value index.js:511 value index.js:90 Component index.js:51 onNodeAdded index.js:496 callHook morphdom.js:35 handleNodeAdded morphdom.js:140 handleNodeAdded morphdom.js:158 morphEl morphdom.js:407 morphEl morphdom.js:219 morphEl morphdom.js:332 morphEl morphdom.js:219 morphEl morphdom.js:332 morphEl morphdom.js:219 morphEl morphdom.js:332 morphEl morphdom.js:219 morphdomFactory morphdom.js:463 value index.js:386 value index.js:291 value index.js:269 value index.js:7 value index.js:58 promise callbackvalue/< index.js:53 promise callbackvalue index.js:51 sendMessage index.js:242 value index.js:252 later debounce.js:8 setTimeout handler*debounce/< debounce.js:12 value index.js:225 emit Store.js:55 emit Store.js:54 value index.js:58