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

Returning true from OnNext does not advance the wizard. #152

Closed rhythmicdevil closed 8 years ago

rhythmicdevil commented 8 years ago

The return value is false, the wizard does not advance as expected. When the return value is true the wizard does not advance. My expectation is that the wizard would advance to the next step. Here is content of my onNext() function. Can you tell me if I am doing something wrong or if this is a bug?

        onNext: function(tab, navigation, index){
            /*
             * tracking flag
             */
            var valid = true;
            /*
             * Subjects in wizard order
             */
            var subjects = [
                "localIpAddress",
                "subnetMask",
                "dhcpEnabled",
                "dhcpStartingIp",
                "dhcpEndingIp"
            ];
            /*
             * Get the form data
             */
            var lanConfigurationDto = {
                    localIpAddress : $('input[name="localIpAddress"]').val(),
                    subnetMask: $('input[name="subnetMask"]').val(),
                    dhcpEnabled: $('input[name="dhcpEnabled"]').is(':checked') ? true : false,
                    dhcpStartingIp: $('input[name="localIpAddress"]').val(),
                    dhcpEndingIp    : $('input[name="localIpAddress"]').val()
            }

            if(index == 1){
                validate(subjects[0], lanConfigurationDto, function(res){ valid = res; });
            } else if(index == 2) {
                validate(subjects[1], lanConfigurationDto, function(res){ valid = res; });
            }

            return valid; 
        }
VinceG commented 8 years ago

@rhythmicdevil you dont need to return true to advance, return false if you want to prevent advancement.

example: http://vinceg.github.io/twitter-bootstrap-wizard/examples/basic-formvalidation.html