我是新來的ReactJS,並嘗試找到一種方法來禁用兩個div的點擊事件,當用戶提供JavaScript的反饋。提供的任何援助將不勝感激。我怎麼可能做到這一點與下面的代碼:當用戶提供反饋時,禁用點擊事件
var SubmitRating = React.createClass({
FEEDBACK_PHASE: 1, // - user agrees to give feedback and is yet to give
THANKS_PHASE: 2, // - user gave feedback
getInitialState: function() {
return {
"phase": this.FEEDBACK_PHASE
}
},
setPhase: function(phase) {
this.setState({
"phase": phase
});
},
componentWillReceiveProps: function(nextProps) {
if(nextProps.active) {
this.setPhase(this.FEEDBACK_PHASE);
}
},
submitRating: function(rating) {
var currentVideo = this.props.currentVideoData;
this.setPhase(this.THANKS_PHASE);
this.props.submitDone();
//TODO : need to add more parameters which will be sent to rating app
ajaxPost("/answer_rating", {"documentID": currentVideo.talk_id,
"startTime": currentVideo.start_time_sec,
"endTime": currentVideo.stop_time_sec,
"userRanking": rating,
"hashCode": currentVideo.metadata.hash,
"questionText": currentVideo.metadata.question }, function(response){
console.log(response);
});
},
render: function() {
return (
<div className={this.props.active ? "feedback-options-container" : "hidden"}>
<div className={this.state.phase == this.FEEDBACK_PHASE ? "feedback-options" : "hidden"} >
<div className="option-relevant" onClick={this.submitRating.bind(this, 10)}> This video answered correctly </div>
<div className="option-irrelevant" onClick={this.submitRating.bind(this, 1)}> This video did not answer properly </div>
</div>
<div className={this.state.phase == this.THANKS_PHASE ? "feedback-reply" : "hidden"}> <h4> Thanks for your feedback </h4> </div>
</div>
)
},
});
你有作爲回答未標記爲已相當多的問題。請做好標記(如果他們解決了問題),以便其他人也可以從中學習。 [這是你如何回答標記](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) – Dhiraj