Multiple Action Helpers on single element

@lukemelia I agree with your findings on the current state of affairs; it is awkward. When I needed to handle two different interactions on one element, I immediately jumped to the conclusion that all I had to do was add another helper. It was the intuitive option, but cost a fair bit of time debugging to find it didn’t work, hence my push for better documentation on the subject.

This is just a shot-in-the-dark idea as I haven’t given the code a thorough perusing yet, but would it be possible for the {{action}} helper to check for a pre-existing data-action-id attribute? Or maybe something similar to the functionality of jQuery’s addClass would be handy? Would space delimiting the IDs of the registered actions be a good choice?

Inital template:

<div {{action selectPage this}} {{action choosePage this on="doubleClick"}}>
  click me
</div>

First helper gets processed, which adds a new data-action-id:

<div data-action-id="42" {{action choosePage this on="doubleClick"}}>
  click me
</div>

Second helper gets processed, which updates the existing data-action-id:

<div data-action-id="42 43">
  click me
</div>
1 Like