Swaraj ghosh Swaraj ghosh - 19 days ago 4x
Javascript Question

OnClick Event binding in React.js

I would like to pass the parent div id on click of that div or any of child element of the same. But i am unable to achieve it. Please tell me where I am doing mistake. Code is Below.

viewMore: function(i,j){
console.log('You clicked: ', i );

render : function(){
var attributeId = "groups_";
attributeId+= index;
//parent div
<div className="groups" id={attributeId} onClick={this.viewMore}>
<div className="floatLeft"> Group Name: <h3>My Name</h3></div>
<span className="floatRight typeCd">POC</span>
<div className="clearfix"> Key Attributes:
<li> POC 1</li>


Make a new function using bind.

onClick={this.viewMore.bind(this, attributeId)}