我遇到了 jQuery Steps 的问题插入。在采取特定操作之前,必须禁用下一步按钮,如果数据经过正确验证,则应启用该按钮。
所以问题是:如何将下一步按钮设置为默认禁用,以及是否有可用的方法以编程方式启用或禁用下一步按钮?
这是我当前的代码:
HTML:
<div id="steps">
<h3>Write question</h3>
<section>
<input type="text" id="question" placeholder="Question goes here">
<button id="save">Save and do something else</button>
</section>
<h3>Preview</h3>
<section>
<p id="preview"></p>
</section>
<h3>Done</h3>
<section>
<p>Congratulations text goes here</p>
</section>
</div>
jQuery:
//start
$(function(){
$('#steps').steps({
headerTag: "h3",
bodyTag: "section",
transitionEffect: "slideLeft",
stepsOrientation: "vertical"
});
$('#save').click(function(){
$('#preview').html($('#question').val());
//do something else (ajax wise, etc)
if(true) {
//enable NEXT button here...
}
});
});
最佳答案
这个问题很久以前就被问过,但我觉得这可以帮助别人。
jQuery Steps 插件,可以监听 onStepChanging 事件: 除非设置了标志,否则返回 false。
$(function() {
$("#steps").steps({
//Events
onStepChanging: function (event, currentIndex, newIndex){
if(currentIndex==2 && flag==false){
return false;
}
else{
return true;
}
},
});
});
关于jquery - 禁用按钮,直到使用 jQuery Steps 采取特定操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34795287/