I am trying to learn and develop a web app that allows the user to go through folders and view files. (Something like google drive does).
I am using Nodejs and using handlebars to render.
I referred to This link to get the json data. However I can't understand why my function rowSelected is not being triggered.
I haven't had much exposure towards Handlebars, but I can't seem to point out the problem in this.
Let me know if I need to provide any more code snippets. I don't want to include any jQuery or Ajax inside this.
Thank you
This is my content.hbs
<body>
<div style="align:center">
<table>
<tr>
<th>Name</th>
<th>Is Folder</th>
<th>Date Modified</th>
</tr>
{{#each contents}}
<tr onclick="rowSelected({{{json this}}})">
<td>{{name}}</td>
<td>{{isFolder}}</td>
<td>50</td>
</tr>
{{/each}}
</table>
</div>
Server.js
hbs.registerHelper('json', (context) => {
console.log(context);
return JSON.stringify(context).replace(/"/g, '"');
});
var rowSelected = (selectedValue) => {
console.log(`The selected value is ${selectedValue.name}`);
}