下面是反应代码打开fancybox确认计划。如果所有字段都经过验证,那么条件得到为真,弹出窗口打开,如果条件返回false,则它会阻止该操作并返回false。 但在我的情况下,投掷错误后fancybox正在打开。
componentDidMount:function() {
$('.fancybox').fancybox({
helpers : {
overlay : {
closeClick : false
}
}
});
},
validateIt: function(e,resolve,reject) {
if(!this.validateAll()) {
e.preventDefault();
return false;
} else {
$(this.refs.submitFlightPlan).attr('href','#flightPlanPopup');
$(this.refs.submitFlightPlan).trigger('click');
resolve(true);
}
},
validateFlightPlan: function(e) {
this.state.mapError = '';
this.state.message = '';
this.setState(this.state);
return new Promise(function(e,resolve,reject) {
this.validateIt(e,resolve,reject);
}.bind(this,e));
},
render: function() {
var PopupProps = {
id: 'flightPlanPopup',
header: 'Confirm plan?',
message: 'Are you sure you want to save the Plan?',
yesCallBack: this.reservePlan,
isOkButton: false
};
return (
<div className=" saveFlightPlan">
<a href="javascript:void(0)" className="btn primeBtn fancybox" ref = "submitFlightPlan" onClick = {this.validateFlightPlan.bind(this)}>Save Flight Plan</a>
</div>
);
}