在引导演练中,我们有下一个和上一个按钮。在此单击下一步按钮,我们将进入下一步。
但是我想添加条件,如果该输入字段为空,则演练不应移至下一个,它应仅停留在当前步骤上。
以下是参考代码:
rec = {
aa: responseData[i].fields.aa,
bb: responseData[i].fields.bb,
cc: responseData[i].fields.cc,
element: responseData[i].fields.element_selector,
placement: responseData[i].fields.modal_placement,
title: responseData[i].fields.modal_title,
content: responseData[i].fields.modal_content,
onShow: show_fn,
onNext : function () {
var dir = 'next';
this_selector = this.element;
this_selected_elem = $(this_selector).find('option:selected').val();
console.log(this_selected_elem);
if(this_selected_elem == ''){
console.log('--prev---');
}
}
}
//rec 正在推入 allRec 数组。
aps.workFlow.allRec.push(rec);
for(var i = 0 ; i< aps.workFlow.allRec.length; i++){
if (aps.workFlow.allRec[i].aa == walkthroughType){
element_selector = aps.workFlow.allRec[i].element;
selected_elem = $(element_selector).find('option:selected').val();
open_elem = aps.workFlow.allRec[i].onShow;
if(selected_elem == undefined || selected_elem == ''){
aps.workFlow.allRec1.push(aps.workFlow.allRec[i]);//Adding records in allRec1 array which is going to pass as walkthrough steps.
}
}
}
aps.walk.setupBootstrap(); // this is the function which is having tour steps setup.
aps.walk = {
setupBootstrap : function(){
//dir = 'next';
tour = new Tour();
tour.end();
//tour.addSteps(aps.workFlow.arrayRec1);
console.log('-----aps.workFlow.allRec1-------------')
console.log(aps.workFlow.allRec1)
tour.addSteps(aps.workFlow.allRec1);
tour.init();
tour.start();
if (tour.ended()) {
$('<div class="alert alert-info alert-dismissable"><button class="close" data-dismiss="alert" aria-hidden="true">×</button>You ended the demo tour. <a href="#" data-demo>Restart the demo tour.</a></div>').prependTo(".content").alert();
tour.restart();
}
$(document).on("click","#proposal_command_list #create_tour", function(e) {
e.preventDefault();
if ($(this).hasClass("disabled")) {
return;
}
//tour._options.steps = aps.workFlow.arrayRec1
tour._options.steps = aps.workFlow.allRec1
return $(".alert").alert("close");
});
//tour.restart();
}
}