Could I use concatenate {{> afQuickField name='item.{{index}}.name' }}?


#1

I would like to concatenate field name like this

{{#each data}}
   {{> afQuickField name='item.{{index}}.name'}}
   {{> afQuickField name='item.{{index}}.qty'}}
   {{> afQuickField name='item.{{index}}.price'}}
{{/each}}

Please help me.


#2

I think {{> afQuickField name='item.[index].name'}} should work, provided you have an index helper since spacebars currently does not have an index. But it will have them with the new version.

In the meantime, you can also take a look at https://github.com/Gaelan/meteor-each-with-index/ for indexes.


#3

I would like to pass data items in spacebar of spacebar:

data = [
   {index: '001', ..............},
   {index: '002', ..............},
   {index: '003', ..............}
]

#4

Like concatenate in JS "items." + index + ".name".
Please help me.


#5

You could try nesting

{{#each data}}
  {{#each item}}
    {{> afQuickField name='name'}}
    {{> afQuickField name='qty'}}
    {{> afQuickField name='price'}}
  {{/each}}
{{/each}}

#6

I would like to each with the customer array of object like this

// Schema
items:{
   type: [Objec]
},
'items.$.name':{
   type: String
},
'items.$.qty':{
   type: Number
},
'items.$.price':{
   type: Number,
   decimal: true
}

// Template
...
{{#each items}}
   // would like to custom "name" by index
   {{> afQickField name="items."{{index}}".name"}}
   {{> afQickField name="items."{{index}}".qty"}}
   {{> afQickField name="items."{{index}}".price"}}
{{/each}}

// Helper
Template..........helpers({
   items: function(){
      var itemsVal = [
         {index: 0, name: 'A', qty: 4, price: 15},
         {index: 1, name: 'B', qty: 4, price: 15},
         {index: 2, name: 'C', qty: 4, price: 15},
      ]
      
      return itemsVal;
   }
})

#7