Bootstrap Carousel with Handlebars.js

1.9k views Asked by At

I am getting my carousel data using Handlebars.js. I am wondering how to use Handlebars to get the current active item from the carousel.

<script id="template" type="text/x-handlebars-template">
    {{#each}}
          <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">

          <!-- Wrapper for slides -->
          <div class="carousel-inner">
            {{#each}}
                {{this.title}}
            {{/each}}
          </div>

          <!-- Controls -->
          <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
            <span class="glyphicon glyphicon-chevron-left"></span>
          </a>
          <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
            <span class="glyphicon glyphicon-chevron-right"></span>
          </a>

          <!-- Indicators -->
          <ol class="carousel-indicators">
            {{#each}}
                <li data-target="#carousel-example-generic" data-slide-to="{{this.id}}" {{#ifEquals this.id 1}} class="active" {{/ifEquals}}></li>
            {{/each}}
            <span id="number"> </span> 
          </ol>
        </div> <!-- Carousel -->
    {{/each}}
</script>

Any ideas how to check the current active carousel using Handlebars?

0

There are 0 answers