I'm trying to generate JSON for display clickable Konva object. All attributes working as expected except onClick.
How to pass a JS function in JSON with Laravel Respons::json()?
Here's what I've tried.
return Response::json([
'status' => 'completed',
'message' => 'Question ID:'.$id.' Retreived',
'data' => [
"attrs" => [
"width" => 1200,
"height"=> 200
],
"className" => "Stage",
"children" => [
[
"attrs"=>[],
"className"=>"Layer",
"children"=>[
[
"attrs"=>[
"x"=>125,
"y"=>100,
"text"=>"Test Text",
"onClick"=> "{() => console.log(test)}",
"fontSize"=>25,
],
"className"=>"Text"
]
]
],
]
]
], 200);
but I got this error
TypeError: selfListeners[i].handler.call is not a function. (In 'selfListeners[i].handler.call(this, evt)', 'selfListeners[i].handler.call' is undefined)