Custom link / button actions #2303
Replies: 2 comments 8 replies
-
How about a hash pattern, say |
Beta Was this translation helpful? Give feedback.
-
I would probably go for option 2, because as I'm seeing it you'd only need to add the code to the |
Beta Was this translation helpful? Give feedback.
-
I am working on a requirement to add support for custom "Sign In" CTAs which will be used in different sections of the page (marquee, cards etc), but this can be generalised to any custom action that needs to be triggered after a link is clicked.
My solution relies on using custom hashes that can be used to identify the action and then either listen to the hash change or set custom behaviour if the clicked element contains the hash.
Example:
Link element with URL: https://account.adobe.com/#login
account.adobe.com can be used as a fallback, since it will redirect the user to login page if logged-out.
Option 1 - listen to hash change
PRO: this can be repurposed for multiple custom actions
CON: might conflict with existing
hashchanges
from blocks, example modal.jsOption 2 - set custom behaviour based on action
PRO: everything is isolated to links decoration
CON: have to cover multiple specific elements
Both options require to add code in
utils.js
, which will eventually get executed regardless whether the custom actions are present on the page or not. I am inclined to go with option 1 where the entire solution would live in a single place, but would love some feedback and suggestions from the community.Beta Was this translation helpful? Give feedback.
All reactions