Phx-click not working

what are the reasons that can be possible to make phx-click not working and doesn’t fire an event ?

because i did every thing right but the handle event doesn’t fire up.

image

I am not able to reproduce this issue using your code in a project created with the command: mix phx.new test --live

Try to create a new project using the command above, and see if the code you posted works for you then.
If that is the case it is probably due to incorrect project configuration, and you can then see if you can find a difference between the project that works and the one that doesn’t

1 Like

yes it’s work in a different project because the code is correct, just in my project it doesn’t work. so for that i am asking what can be the reasons for preventing the phx-click work

From my experience, phx-click events not firing typically means your LiveSocket isn’t set-up correctly. Check that you have your config all set-up correctly, and if you have then look in your server log to see if LiveSocket is connected, or look in your browser console to see if there is anything failing

2 Likes

yes that exactly what happen when i take a look in my browser there are something undefinedn when i fixed it it worked thanks

That’s so right. what of in an event where all sockets are well connected but the event is not just responding…

Do these events belong to the parent LiveView or its components? Do you happen to possess a handle_event function that covers all scenarios? Could there be repeated IDs within the DOM? I kindly request you to assess these checkpoints, or even better, provide a sample illustrating the issue.