I am creating a table which includes two rows with dynamic numbers of td.
The important part is to set the width for each td and the width has been calculated and passed to view.
tdWidth: 100/numberOfChars => which gives a percentage for width
I am using following code but it is not working:
<table>
<tbody>
<tr>
{{#each array}}
<td style='width: {{tdWidth}}%;'>{{this}}</td>
{{/each}}
</tr>
</tbody>
</table>
any helps appreciated.
@nknapp please help!
What issue are you currently having?
More code would be needed to help resolve the issue.
@magikstm actually tdWidth comes from server but it is not being rendered in client. while I check the source on client, it shows:
@amirzandi could you please share more of your code?
Especially the part that creates the "tdWidth" value as well as how you link it to that part of your page.
@magikstm
this is the server side:
res.render('./game/phrase_box', {
layout: false,
incorrects: result.incorrects,
corrects: result.corrects,
numberOfChars: result.numberOfChars,
tdWidth: 100 / numberOfChars
});
this is the client side:
{{#if incorrects}}
{{#if corrects}}
Most helpful comment
You're iterating in "corrects" in your "each" statement, but that object doesn't hold the "tdWidth" object.
I think you may need to change this:
{{tdWidth}}
To this:
{{../tdWidth}}
Ref: http://handlebarsjs.com/ (under "Handlebars Paths")