There’s a <a id="notifications"> tag where the user clicks.
All of this is working, except for the phx-click part. If I set the lists display to block, the click works fine. However I only want the list to be displayed once the user clicks the icon, however if I hide the list with display: none;, liveview doesn’t correctly setup phx-click listeners. Is there a way to fix this?
I think something else is going on here, because I am working on a project where LiveView drives a tabbed interface and all tabs other than the current tab are display: none.
Sorry, that’s just a typo of where I copied it over from my editor(i removed some other html attrs that were there but not relevant to this, and I left an extra quotation in there, but there’s no double double quote in my actual markup, so it’s not related to that). Fixed.
It might copy the HTML into a new element then add that to the page. So if phx-click is relying it to be the same element as when the page renders, that could be an issue. Is there a way to reinitialize phx-click listeners at runtime?
That’s probably the reason, yes. I think that that will trigger after the LiveView JS-runtime has inserted the click listeners.
I unfortunately do not know of a way to re-initialize them at runtime.
Maybe it is worth it to manage the modal from within LiveView (or, if necessary, a LiveView JS-hook) instead?