Is there a way to install multiple events for tap? E.g. on tap close the sidebar and open a lightbox?
Thanks.
Is there a way to install multiple events for tap? E.g. on tap close the sidebar and open a lightbox?
Thanks.
Handling multiple events You can listen to multiple events on an element by separating the events with a semicolon ;.
Example: on="submit-success:lightbox1;submit-error:lightbox2"
Multiple actions for one event You can execute multiple actions in sequence for the same event by separating the actions with a comma ','.
Example: on="tap:target1.actionA,target2.actionB"
There doesn't appear to be a way to chain actions.
You could try;
<button on="tap:my-lb.open" on="tap:sidebar1.close">test</button>
Or
<button on="tap:my-lb.open,sidebar1.close">test</button>
The use of semicolons makes this possible.
<button on="tap:my-lb.open;tap:sidebar1.close">test</button>
https://www.ampproject.org/docs/fundamentals/spec#on
P.S.: I'm not sure if it works on the same event twice. But it works with different ones like tap:action;change:action
I got this to work using one on
attribute just fine:
<button on="tap:lightbox-1.close,lightbox-2">Next</button>
lightbox-1
and lightbox-2
). –
Ferromanganese You can listen to multiple events on an element by separating the events with a semicolon ;.
Example: on="submit-success:lightbox1;submit-error:lightbox2"
To trigger multiple componets with tap on a single component, you need to separate componentX.action parts with commas. Here ans16 and explanation16 are two components to be shown or hidden after tapping.
<div on="tap:ans16.toggleVisibility,explanation16.toggleVisibility" role="button" tabindex="16">Answer[=]</div>
<div id="ans16" hidden>D</div>
<div id="explanation16" hidden>Explanation: </div>
Check here for a working amp page. It also uses role and tabindex attributes which are required to qualify for a Google AMP page indexing.
© 2022 - 2024 — McMap. All rights reserved.