我已经在这里问过这个问题 Creating next and back button on tabs bootstrap 3 wizard?
但我现在已经扩展它以在最后一个选项卡上添加完成,但现在我在删除第一个选项卡上的后退按钮时遇到问题,这是我的代码
$('.step-back, .step-next').on('shown.bs.tab', function (e) {
currentStep()
})
var previousButton = '<a href="#" data-toggle="tab" class="step-back">back</a>';
var nextButton = '<a href="#" data-toggle="tab" class="step-next">next </a>';
$(".wizard-navigation").html(previousButton + nextButton);
function currentStep() {
var stepsLong = $('.tab-pane').length;
var currentVal = $('.tab-pane.active').attr("data-step");
currentVal = parseInt(currentVal);
var prev = currentVal - 1;
var next = currentVal + 1;
if ( currentVal == stepsLong) {
$(".step-next").html("finish").attr('href', '#step' + next);
}
else {
$(".step-next").html("next").attr('href', '#step' + next);
}
if (currentVal == 0) {
$('.step-back').addClass('hidden');
}
else {
$(".step-next").removeClass('hidden');
}
}
这是工作 fiddle http://jsfiddle.net/52VtD/9206/
如果用户在第一个选项卡上删除后退按钮,我需要什么
这是另一个工作 fiddle http://jsfiddle.net/52VtD/9207/
最佳答案
http://jsfiddle.net/52VtD/9209/
我在你的步进器中添加了这个逻辑:
if(currentVal == 1) $('.step-back').hide()
else $('.step-back').show()
这个也解决了您的点击问题:http://jsfiddle.net/52VtD/9211/
您的问题是您绑定(bind)到 .shown,但从来没有抛出显示事件,我向您的初始化代码添加了一个制表符(“显示”)。
关于jquery - Bootstrap 3 向导?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27077582/