简体   繁体   中英

loop inside of loop in handlebars.js

I am using handlebars.js. I have a loop of flight.LegsOut and I am really only using the "first" and the "last" of the flight.LegsOut elements. But inside of the loop I have a modal popup - tagged - "dropdown popup". The popup will show data from all of the flight.LegsOut elements. But the popup is placed inside of the "last" loop (for css placement reasons). So my question is: How can I do a loop of the whole Flight.LegsOut inside of the "last" of the flight.LegsOut in order to display data from it in the modal popup - tagged "dropdown popup" ?

{{#each Flight.LegsOut}}
                        {{#if @@first}}
                        <figure class="srbl-img">
                            <img src="/content/images/airline/{{Carrier}}.png" />
                        </figure>{{/if}}

                        {{#if @@last}}
                        <span class="srbl-col2">
                            <font class="fcc-tab">{{IATAFrom}} </font>
                            <font class="fcc-right">
                                {{ time DepartureDateTime }}
                                <br>
                                Rome
                            </font>
                        </span>
                        <span class="srbl-col3">
                            {{ readableTime ../../Flight.TravelTimeOut}}
                            <br>
                            <font class="green">
                                {{ leglength ../../Flight.LegsOut}} <a href="#"><img alt="" src="/content/images/package/info-icon.png"></a>
                                <!-- dropdown popup -->
                                <div class="popup-tab">
                                    <span class="arrow-indicate"><img alt="" src="/content/images/package/top-indecate.png"></span>
                                    <div class="popup-innertab">
                                        <div class="popup-left">
                                            <h3>Airport</h3>
                                            <p>XXX (Milano)</p>
                                        </div>
                                        <div class="popup-right">
                                            <h3>Waiting time</h3>
                                            <p>1h 22m</p>
                                        </div>
                                        <div class="clear"></div>
                                    </div>
                                </div>
                                <!-- dropdown popup -->
                            </font>
                        </span>
                        <span class="srbl-col4">
                            <font class="fcc-tab">
                                <strong>{{IATATo}}</strong><br>
                                Iasi
                            </font>
                            <font class="fcc-right">
                                {{ time ArrivalDateTime }}

                            </font>
                        </span>
                        <div class="clear"></div>
                    {{/if}}
{{/each}}

Not sure I fully understood the question, how about:

{{#each ../../Flight.LegsOut}}
{{/each}}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM