Modal not opening when doing $emit

Hello together,

I am trying to open a modal within livewire.

Everything seems to be working expect that the event $emit within the function does not work.

I have done the same steps as already in the help with the galaxy only that the event does not fire.

Here is my code:
protected $listeners = [‘open’ => ‘loadComments’];
public function loadComments($feedItemId)
{
$this->emit(‘toggleModal’);
$this->feedItem=FeedItem::query()->whereKey($feedItemId)->first();
$this->comments=Comment::query()->where(“commentable_id”,$feedItemId)->get();
$this->commentsCount=$this->comments->count();
$this->emit(‘toggleModal’);
}

The toggleModal function is called as following:
window.livewire.on(‘toggleModal’, function () {
return $(’#galaxy-form-modal’).modal(‘show’);
});

I see that the open emitTo works but then does not fire the event toggleModal and only sets the $feedItem, $commentsCount and the $comments.

What could be the problem? Could it be that the javascript event is in the wrong file but why does $this->emit(‘toggleModal’) not work?

Thank you for your feedback!