javascript - Dynamically generated input onChange function loses additional argument context -
i trying pass option.title
parameter onchange
function of corresponding generated radiogroup
form component.
onchange
receives correct event, option.title
value last 1 that's rendered. how bind option.title
it's component's onchange
? presently, when event triggered, option.title
has taken last generated element's value - , shown regardless of element triggered onchange
.
generatelist(){ var list = [] (var in configs){ var option = configs[i] list.push( <div> <div classname="optiontitle">{option.title}</div> <radiogroup onchange={(e) => this.handleradiochange(option.title, e)} classname="configcontainer" horizontal> {this.generateradio(option.options, option.title)} </radiogroup> </div> ) } return list }
try this
generatelist(){ return configs.map((option) => (<div> <div classname="optiontitle">{option.title}</div> <radiogroup onchange={(e) => this.handleradiochange(option.title, e)} classname="configcontainer" horizontal> {this.generateradio(option.options, option.title)} </radiogroup> </div> ) ) }
Comments
Post a Comment