Yo!
Sorry if this has been asked already. How do I get the index of a loop created via merge syntax (used in a template component). For example, something like this (which doesn't work):
Cheers!
Louis
Sorry if this has been asked already. How do I get the index of a loop created via merge syntax (used in a template component). For example, something like this (which doesn't work):
{{#$Model.MyLovelySkuidModel.data}}
<li>{{index}} - {{{Name}}}</li>
{{/$Model.MyLovelySkuidModel.data}}
Cheers!
Louis
-
5,144 Points
Posted 1 year ago
Rob Hatch, Official Rep
-
44,168 Points
If your template is bound to a model it will loop over all the rows in that model. You don't need the first or last line. {{index}} -{{Name}} will work fine.
I think I am misunderstanding something here.....
I think I am misunderstanding something here.....
-
5,144 Points
H Rob,
So this is where a template isn't bound to a model. Instead, I'm just using merge syntax to loop through the rows of a model. I need to include HTML both above and below the looped area - which is why I can't just bind the template to a model and have it loop automatically.
e.g:
Template 1: Some HTML
Template 2: Repeating list bound to a model
Template 3: Some more HTML
The template syntax interferes with my HTML - hence why I just want to do it all in one template using the merge syntax.
So this is where a template isn't bound to a model. Instead, I'm just using merge syntax to loop through the rows of a model. I need to include HTML both above and below the looped area - which is why I can't just bind the template to a model and have it loop automatically.
e.g:
SOME HTML {{#$Model.MyLovelySkuidModel.data}}If I were instead to use three templates (e.g.)
<li>{{index}} - {{{Name}}}</li>
{{/$Model.MyLovelySkuidModel.data}} SOME MORE HTML
Template 1: Some HTML
Template 2: Repeating list bound to a model
Template 3: Some more HTML
The template syntax interferes with my HTML - hence why I just want to do it all in one template using the merge syntax.
Bill McCullough, Champion
-
12,948 Points
Louis,
Try adding a UI Only formula field to your model and make the formula {{index}}. Then add the formula field to your template.
Thanks,
Bill
Try adding a UI Only formula field to your model and make the formula {{index}}. Then add the formula field to your template.
Thanks,
Bill
-
5,144 Points
Golly - that's done it! Amazing. Cheers Bill!
Related Categories
-
Skuid on Salesforce
- 2274 Conversations
- 181 Followers