I use the Livewire framework in my Laravel, I created a comment feature, I want when I comment the screen will automatically scroll to the comment via the ID that I inserted using JavaScript but when I make a comment it should automatically scroll down but instead it appears
error message “Method AppLivewirePostComment::emit does not exist.”
Please help me
public function store()
{
$this->validate(["body" => "required"]);
$comment = ModelsComment::create([
'user_id' => Auth::user()->id,
"article_id" => $this->article->id,
"body" => $this->body
]);
if($comment){
$this->emit('commentStored', $comment->id);
$this->body = null;
} else {
session()->flash('danger', 'Komentar gagal Ditambahkan!!');
return redirect()->route('data', $this->article->slug);
}
}
$this->emit('commentStored', $comment->id);
I searched on any site but no one discussed this error
ZAKI ULUMUDIN is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.