1

Bootstrap Wizard passes to second tab, but not to third nor further. Event previous not working at all.

I encountered this weird problem and after many attempts to solve it I decided to ask stack for some help.

Event for passing to next tab is triggered correctly at each attempt but works only once. I isolated the significant part of my layout that successfully reproduces the problem and uses only external resources, so to give it a try you only need to paste it to an html file.

Or you can just try it out on JSbin I created here

Source:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
    <form id="rootwizard">
        <div class="navbar">
            <div class="navbar-inner">
                <div class="container">
                    <ul>
                        <li><a href="#tab1" data-toggle="tab">First</a></li>
                        <li><a href="#tab2" data-toggle="tab">Second</a></li>
                        <li><a href="#tab3" data-toggle="tab">Third</a></li>
                        <li><a href="#tab4" data-toggle="tab">Forth</a></li>
                        <li><a href="#tab5" data-toggle="tab">Fifth</a></li>
                        <li><a href="#tab6" data-toggle="tab">Sixth</a></li>
                        <li><a href="#tab7" data-toggle="tab">Seventh</a></li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="tab-content">
            <div class="tab-pane" id="tab1">
            1
            </div>
            <div class="tab-pane" id="tab2">
            2
            </div>
            <div class="tab-pane" id="tab3">
            3
            </div>
            <div class="tab-pane" id="tab4">
            4
            </div>
            <div class="tab-pane" id="tab5">
            5
            </div>
            <div class="tab-pane" id="tab6">
            6
            </div>
            <div class="tab-pane" id="tab7">
            7
            </div>
        </div>  
    </form>
    <button id="add_wizard_previous" class="btn btn-default">
        Previous
    </button>
    <button id="add_wizard_next" class="btn btn-default">
        Next
    </button>
</div>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="http://vadimg.com/twitter-bootstrap-wizard-example/jquery.bootstrap.wizard.js"></script>
<script>
$(document).ready(function() {
    $('#rootwizard').bootstrapWizard({
        'tabClass': 'nav nav-tabs',
            onNext: function(tab, navigation, index) {
        // console.log('event is intercepted at each time');
            return true;
            }
    });
    $('#add_wizard_previous').on('click', function() {
        $('#rootwizard').bootstrapWizard('previous');
    });
    $('#add_wizard_next').on('click', function() {
    //  console.log('event works at each click');
        $('#rootwizard').bootstrapWizard('next');
    });
}); 
</script>
</body>
</html>
4

1 回答 1

1

There is a problem with the lib version you refer to in the bin example.

If you use version 1.3.1 of the wizard lib (https://github.com/VinceG/twitter-bootstrap-wizard/blob/master/jquery.bootstrap.wizard.js) everything works fine.

于 2016-02-28T06:19:49.760 回答