1

Hy i want to toggle a content in an amp-list, I followed the instructions of the following post: AMP: easy way to toggle a CSS class?, and it works fine.

The problem is that i'm in an "amp-list" and i want to open only the specific content that i clicked on and not all the list contents.

This is the code:

    <amp-list width="auto" height="1500" layout="fixed-height" src="/SRC/json/box.json" class="m1">
      <template type="amp-mustache" id="amp-template-id">
        <section>
          <h1 tabindex="1" role="tab" on="tap:collapsed.toggleVisibility">
            <!--box1-->
            <div class="box"> 
              <span class="title">
                <span>{{title}}</span> |
                <span>{{title2}}</span>
              </span>                       
            </div
            <!--end box1-->
            <button [text]="visible ? 'Show Less' : 'Show More'" on="tap:AMP.setState({ visible: !visible})">Show More</button>
          </h1>
          <div  [class]="visible ? 'show' : 'hide'" class="hide collapsed" id="{{item}}">
            <div class="content">
              <div class="desc">text text text</div>                     
            </div>
          </div>
        </section>
      </template>
    </amp-list>

do you have an idea how to do it? thanks

Bachcha Singh
  • 3,850
  • 3
  • 24
  • 38

0 Answers0