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

Show/hide demo broken #209

Open abbottmw opened 7 years ago

abbottmw commented 7 years ago

On the demo where you can show/hide tabs or steps, after you hide a tab, the next and previous do not work correctly. It skips over steps.

http://vinceg.github.io/twitter-bootstrap-wizard/examples/remove-step.html#

VinceG commented 7 years ago

@abbottmw Yeah, i think because it does not call the refresh to reset the index count.

abbottmw commented 7 years ago

The :visible fix I added should resolve this.

Adam-78 commented 7 years ago

The show/hide methods do not work even with the :visible fix added? Doing the following should show tab 3 and its tab panel - nothing happens?

$('#rootwizard').bootstrapWizard('display', 3);

Currently I'm having to revert to the standard bootstrap method:

  $('#rootwizard li:eq(2) a').tab('show') // Select third tab (0-indexed)

When can we expect a fix?

Adam-78 commented 7 years ago

Many thanks. That worked like a charm.


From: Vincent Gabriel notifications@github.com

Try

$('#rootwizard').bootstrapWizard('show', 2);

Adam-78 commented 7 years ago

Is it possible to call the show method from inside the onInit event. The following doesnt work:

 $('#rootwizard').bootstrapWizard({
       'onInit': function (tab, navigation, index) {
            var lastTabIndex = $("#LastTabIndex").val();
            if (lastTabIndex)
                  $('#rootwizard').bootstrapWizard('show', lastTabIndex);

        }
   });
VinceG commented 7 years ago

@Adam-78 without the condition does $('#rootwizard').bootstrapWizard('show', x); work at all inside onInit?

Adam-78 commented 7 years ago

I get console error:

TypeError: this.data(...) is undefined

In the debugger it highlights the following line:

  return this.data('bootstrapWizard')[options](args);

I think it's because I'm trying to call the following from within $('#rootwizard').bootstrapWizard({...})

$('#rootwizard').bootstrapWizard('show', x);
VinceG commented 7 years ago

@Adam-78 yeah it's impossible since onInit is called right after it's initialized.

i was able to make it work with the following

$('#rootwizard').bootstrapWizard({
        'onInit': function (tab, navigation, index) {
            setTimeout(function() {
              $('#rootwizard').bootstrapWizard('show', 2);
            }, 1);
        }
      });