Wire:click doesn't trigger function with 2 word variables passed to back end?

What seems to be the problem:
When trying to do a wire:click and pass a post title to my backend, the wire click does not trigger the function when the “post title” has two words or more. But if a post title is a single word, it triggers my function. Is there a way around this?
Steps to Reproduce:
Front End
<button wire:click="selectPost({{ $post->id }}, {{ $post->title}})">Delete</button>

Back End

public function selectPost($id, $title)
{
    dd("Working");
}

Are you using the latest version of Livewire:
Yes

Do you have any screenshots or code examples:

but in the blade

<button wire:click="selectPost({{ $post->id }}, {{ $post->title}}, 'delete')">Delete</button> // 3 arguments

and in component

public function selectPost($id, $title) // 2 arguments
{

Missing something?

My bad, I left that in there. But the problem still remains that I am not able to trigger my function if the post title has 2 or more words. If it has one word, it works. Am I doing something wring or is this a Livewire thing?

I really don’t know, not faced this before. But, if you’re passing the id, why you need pass the tittle too if this last you can get it in backend?

In the case of editing the post title, I just wanted to pass the post title to the front end instead of fetching the post and then setting the value. a Bit pedantic I’m sure, but if its not possible, I will just do it that way.

Hi,

Hopefully you have this sorted now but can you try putting {{ post->title }} in quotes in the component?

<button wire:click="selectPost({{ $post->id }}, '{{ $post->title}})'">Delete</button>

Alternatively you can typehint the selectedPost $id paramater method,

public function selectPost(Post $post, $title)
{
    dd("Working");
}

This should get the selected model and you don’t need to then use Post::find(id).

Hope this helps.

Hi, thank you @NigelDorning, this worked as I hoped it would!

Hi,

Not a problem. Glad I could help.