amp.dev icon indicating copy to clipboard operation
amp.dev copied to clipboard

AMP-Selector : how to bind selected attribute dynamically on page load

Open gskaushal92 opened this issue 5 years ago • 1 comments

<amp-selector class="tabs-with-selector" role="tablist" > <div id="sample3-tab1" role="tab" aria-controls="sample3-tabpanel1" option="0" >Tab one</div> <div id="sample3-tab2" role="tab" aria-controls="sample3-tabpanel2" option="1">Tab two</div> <div id="sample3-tab3" role="tab" aria-controls="sample3-tabpanel3" option="2">Tab three</div> </amp-selector>

  1. Let say I am dynamically populate three option inside amp-selector using amp-list.
  2. Now I want to select the second option by default on page load dynamically
  3. What is the right way to do that.
  4. amp is not allowing me to bind [selected] attribute.

gskaushal92 avatar Jul 24 '21 13:07 gskaushal92

If you want to evaluate binding on load (in an amp-list) you need to set the binding="always" attribute.

sebastianbenz avatar Jul 26 '21 17:07 sebastianbenz