Files
openfoodnetwork/app
David Cook e31c16df43 Delegate events to the parent element
Ok so I wasn't as smart as I thought I was. The stimulus controller knows when its element is added/removed from the DOM (and calls connect/disconnect appropriately). But if any child elements are added, they don't automatically have my new event handlers.

So I borrowed jQuery's event delegation concept, and listen for any events that 'bubble' up to the controller element, and delegate them as needed.

Alternatively, maybe I could have used a Mutation Observer, but I think it's best to avoid where possible.

Or of course, we could just revert my change and keep the 'data-action's in the HTML. I'm curious to hear opinions on this.."
2025-02-20 12:46:27 +11:00
..
2024-09-10 13:29:40 +10:00
2023-09-12 23:19:05 +09:00
2024-12-10 05:34:33 +05:00
2025-02-12 16:01:21 +01:00
2025-02-20 12:15:53 +11:00