Does anyone know if it is possible to put a for loop into a jquery template?
For example if I have something like ${userCap}
where the value of userCap is 10, how could I add a for loop to the template to add options to a select while i is less than userCap?
<select>
{{for(i=1; i<=userCap; i++)}}
<option value="${i}">${i}</option>
{{/for }}
</select>
As per Bergi's request - the plugin I am using is... jQuery Templates https://github.com/BorisMoore/jquery-tmpl
The documentation suggests it cannot.
However you can use each
:
<select>
{{each(i) values}}
<option value="${i}">${i}</option>
{{/each}}
</select>
See this fiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With