Created
May 18, 2017 06:07
-
-
Save pk936/5832c517314267fc85fe1b1b28cc9185 to your computer and use it in GitHub Desktop.
I want to access custom attribute in option tag in select
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
render(){ | |
return (<select id="selectTemplate" ref={(input) => this.templateSelect = input}> | |
<option value="0" disabled selected>Select Template</option> | |
{( | |
()=>{ | |
console.log("Templates", this.props.templates) | |
return this.props.templates.templates.data.map((template, index) => { | |
console.log("template.id::::::::::", template.id) // fine | |
return <option key={template.id} value={template.attributes.name}>{template.attributes.name}</option> | |
}) | |
} | |
)()} | |
</select>) | |
} | |
somemethod(){ | |
console.log(this.templateSelect.value) // value is shown | |
console.log(this.templateSelect.key) // undefine | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment