I'm using handlebars with a table with many columns. The table has data from my database, arranged by ID. A button on each row (list of users), will open up a modal dialog for user information. I have my list of users populated in my template with the users in an array as a handlebars template.
I want to be able to display the correct user data on the modal based on which user's button was clicked, as each row is a different id.
I am trying code like this:
{{{allUsers.html_button_id.userName}}}
But as I've seen in other questions like this one, they suggest I use a helper function. I have tried that too, and have a return var helper like this:
getDataFromDB : function(key, index, options) {
return key[index].value;
}
Where in use:
{{getDataFromDB userProfile index}}
But still not coming up with anything. I cannot put in a variable into that, it says that it is invalid. I have a button that has an ID, which I want to pass to this helper function so I can use the ID as the index to iterate through my array depending on which button the user presses. Any idea how to accomplish this? I feel like I'm close