VinceG / twitter-bootstrap-wizard

This twitter bootstrap plugin builds a wizard out of a formatter tabbable structure. It allows to build a wizard functionality using buttons to go through the different wizard steps and using events allows to hook into each step individually.
MIT License
1.39k stars 676 forks source link

Navigating over hidden steps? #110

Closed davidkeaveny closed 9 years ago

davidkeaveny commented 9 years ago

I am implementing a wizard process that needs to hide one or more tabs based on selections made by the user in earlier tabs. However, when a tab is hidden, the navigation does not move to the next visible tab (for instance, on the http://vadimg.com/twitter-bootstrap-wizard-example/examples/remove-step.html sample page, hide the tab "Fourth" by entering 3 in the textbox and clicking Hide, then use the Next button to navigate forwards - when you reach the hidden tab, the content is still rendered although the tab is hidden.

Is there a way of implementing such branching logic, especially where different tabs will be displayed based on earlier choices?

VinceG commented 9 years ago

@davidkeaveny are you calling resetWizard after changing the visibility of the tabs?

sandiktopas commented 9 years ago

Could you explain in more detail where it is necessary to call resetWizard in this example: http://vadimg.com/twitter-bootstrap-wizard-example/examples/remove-step.html ? Does it help in this situation or it is needed to do something more?

davidkeaveny commented 9 years ago

@VinceG I am talking about the Remove Step example at the link above - not in my own code. Unless I am misunderstanding what the demo is supposed to be showing, it doesn't appear to function correctly, as you can't navigate past a hidden step.

lordelph commented 9 years ago

@davidkeaveny - did you resolve this? I'm having a similar problem. For example, if I set up a wizard and then hide one of the tabs like this:

$('#mywiz').bootstrapWizard('hide', 2);
$('#mywiz').bootstrapWizard('resetWizard');

the tab does not get skipped when next is pressed

lordelph commented 9 years ago

What what it's worth, I altered nextIndex and previousIndex to look for a tab which is visible:

    this.nextIndex = function() {
        var idx;

        for (idx=$navigation.find(baseItemSelector).index($activeTab)+1;
             idx <= obj.navigationLength();
             idx++) {

            if ($navigation.find(baseItemSelector + ':eq(' + idx + ') a').is(":visible")) {
                break;
            }
        }
        return idx;
    };
    this.previousIndex = function() {

        var idx;

        for (idx=$navigation.find(baseItemSelector).index($activeTab)-1;
             idx >= 0;
             idx--) {

            if ($navigation.find(baseItemSelector + ':eq(' + idx + ') a').is(":visible")) {
                break;
            }
        }
        return idx;
    };
VinceG commented 9 years ago

@lordelph that's great. let me know if you have the time to create a pull request.