How can one use each
input values in events
? Hope my below code will explain you well.
HTML:
<template name="UpdateAge">
{{#each Name}}
<div data-action="showPrompt">
<div>
Some content
</div>
<div>
<div>
Some content
</div>
</div>
<div>
Name : {{name}}
Age : <input type="text" name="age" value="{{age}}"/> //I need to access age values in event
</div>
</div>
{{/each}}
<template>
JS:
Template.UpdateAge.events({
'click [data-action="showPrompt"]': function (event, template) {
console.log(event.target.age.value); // TypeError: event.target.age.value is undefined
}
});
I dont know whether my approach is good for passing parameter values to events
so suggestions are welcome.
event.target
was undefined, does it? However, hardly any target does have an.age
property, so accessing.value
there would throw. – Tell<div>
does not magically gain a.age
property by that. – Tell