我遇到了一个问题,其中创建了onClick事件的多个进度栏,但是当我单击进度栏时,每个其他进度栏的onClick事件都被激活。onClick激活其他所有onClick事件
我有一个for循环,推动多个<td>
与进度条在它被渲染。
我想实现的是,当用户点击每个进度条时,不同的细节出现在模态上,具体取决于他们点击哪个进度条。
我正在使用react-overlays模态。
Picture of all the div showing up hidden after clicking on the Progress Bar
谢谢你的帮助!
代码:
getInitialState: function(){
return { showModal: false };
},
close(){
this.setState({ showModal: false });
},
open(){
this.setState({ showModal: true });
},
for loop(
bodyRows[cellIndex].push(
<td id="tableBody">
<div className="progress" role="progressbar" id="progressBarStyle" onClick={this.open}>
<Modal
aria-labelledby='modal-label'
style={modalStyle}
backdropStyle={backdropStyle}
show={this.state.showModal}
onHide={this.close}
keyboard={true}
>
<div style={dialogStyle()} >
Hello
</div>
</Modal>
<div className="progress-meter" data-values={this.calculatePercent(value)}>
{Math.floor(this.calculatePercent(value)) + '%'}
</div>
</div>
</td>
)
)
我想你可以通过一个属性或东西来确定特定的点击。 onClick = {()=> this.open('progressBar1')} – Joel