2

I have the following handlebars template:

   {{#each Lead.leads_controller}}
    <tr>
      <td>
        <strong>{{???}}</strong>
      </td>
      <td class="plus expander">&nbsp;</td>
      <td>{{company}}</td>
      <td>{{web}}/</td>
      <td>{{phone_1}}</td>
      <td>{{phone_2}}</td>
      <td>{{fax}}</td>
    </tr>
    {{/each}}

I want to show a 1 based index for each row in a table. I know previously the collectionView had contentIndex exposed but this does not appear to be the case for the each helper.

I found this that seems to suggest that this is not available for the each helper. Is there any way of making this possible for the each helper?

user229044
  • 232,980
  • 40
  • 330
  • 338
dagda1
  • 26,856
  • 59
  • 237
  • 450
  • 2
    Yes you can. I actually answered this about [http://stackoverflow.com/questions/8870785/positional-index-in-ember-js-collections-iteration](http://stackoverflow.com/questions/8870785/positional-index-in-ember-js-collections-iteration). Please close as this is a repeat question. – Roy Daniels Mar 17 '12 at 14:41
  • It does not work with the each helper. I could be wrong but I don't think you have access to _parentView with each. I believe #collection is going to be deprecated at some point soon. – dagda1 Mar 17 '12 at 16:01
  • What doesn't work? Did you run the jsFiddle? – Roy Daniels Mar 17 '12 at 16:09
  • it does not work with #each. That is the point. Can you read the comment I wrote above. – dagda1 Mar 17 '12 at 16:27
  • 1
    So [this jsFiddle](http://jsfiddle.net/ud3323/rTMEg/) isn't what you're looking for? That does not solve your issue? You get access to contentIndex within the each helper. Is that not what you're looking for? – Roy Daniels Mar 17 '12 at 16:31
  • Yes that is it. Thanks a lot. I could not work out how to get _parentView from each. – dagda1 Mar 17 '12 at 16:51
  • 2
    How can we change the index to start count form 1 (like non-developers do)? – Ido Ran Oct 28 '12 at 13:45
  • Related question with answer for most recent Ember: http://stackoverflow.com/a/17788658/1877270 – chrmod Jul 22 '13 at 13:19

0 Answers0