framework7 icon indicating copy to clipboard operation
framework7 copied to clipboard

Accessing parent context in template7 loop

Open jonybuzz opened this issue 9 years ago • 5 comments

This is a (multiple allowed):

  • [x] bug

  • Framework7 Version: 1.6.4

  • Platform and Target: CORDOVA ANDROID

  • Fiddle

What you did

I was trying to access the parent context of a nested loop. This is the template´s context

    [
      {
        "name": "Parent",
        "childs": [
          {
            "name": "Child"
          }]
     }]

And this is the template

{{#each this}}
           {{#childs}}
                <li>{{../name}}</div>
                </li>
           {{/child}}
{{/each}}

I am working with this options: template7Pages: true precompileTemplates: true

Expected Behavior

I wanted to render parent´s name

Actual Behavior

It rendered child´s name, no matter how many ../ I prepended I´m guessing the trigger() function I had to use is responsible

jonybuzz avatar Aug 05 '17 02:08 jonybuzz

Any updates ?

qkdreyer avatar Aug 18 '17 08:08 qkdreyer

Hmm... this works:

{{#each OpenOrders}}
                                <tr>
                                    <td class="tablet-only">{{description}} {{../Id}}</td>
</tr>
{{/each}}

but this not:

{{#each OpenOrders}}
                                <tr>
                                    <td class="tablet-only">
 {{#if ../IAmWorking}}
<td class="tablet-only">{{description}} {{../Id}}</td>
{{else}}
<td class="tablet-only">
<a class="link icon-only" title="Auftrag abarbeiten" onclick="CompanyStartProcessing({{../Id}},{{id}})"><i class="icon f7-icons">fastforward_round</i></a></td>
{{/if}}
</tr>
{{/each}}

in second code {{../Id}} inside the #if is empty. Seems to be tied to the #if nesting.

c0nnex avatar Nov 11 '17 14:11 c0nnex

Additon: onclick="CompanyStartProcessing({{@root.Id}},{{id}})"

works inside the #if block

c0nnex avatar Nov 11 '17 14:11 c0nnex

URL: http://truemoney.com/vascashback50 เซิร์ฟเวอร์: sgp1-MIUI-l7-sec06.awssgp วันที่: 2017/11/12 02:33:08

chittattoo avatar Nov 11 '17 18:11 chittattoo

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jun 24 '18 19:06 lock[bot]