Files
openfoodnetwork/app/webpacker/controllers
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
..
2022-09-29 16:03:45 +02:00
2024-04-10 15:17:56 +01:00
2022-08-08 14:40:58 +10:00
2022-08-08 14:40:58 +10:00
2024-01-17 17:25:24 +11:00
2024-10-14 15:01:18 +11:00