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 False for onTab(Show|Change|Click) Does Not Cancel #39

Closed esheri3 closed 8 years ago

esheri3 commented 11 years ago

Returning false in the onTabShow, onTabChange, and onTabClick events does not prevent the wizard from moving onward to the next section. This was tested using the latest version in Github at the time of writing.

Simple Ex:

$('#container .bootstrap-wizard-component').bootstrapWizard({ 'onTabChange': function(tab, navigation, index) { return false; // does not actual cancel tab change } });

VinceG commented 11 years ago

@esheri3 I'll look into it and will let you know.

Thanks.

VinceG commented 11 years ago

@esheri3 This is confirmed. i'll have to come up with a solution since the onTabShow is triggered when the tab is already shown. I think of updating the readme to state that onTabShow returning false will not prevent tab from showing and just fixing the onTabChange.

natiki commented 10 years ago

Playing with the latest ZIP as of writing it appears that the index parameter value in onTabChange() is always -1. Any chance we can get this bug fixed? Makes it very hard to use this component if you need to do validation before a user changes a tab.

Another idea would be to add an event OnTabChanging() which fires before the tab changes, that way none of the existing code has to change. Returning false there could prevent the change.

VinceG commented 10 years ago

@natiki This is still WIP as the tab changing returning false does not prevent the fire of the method. So there needs to be a different solution. You can use the onNext even to do the same thing. and i am not sure what you meant with the last event addition

natiki commented 10 years ago

@VinceG Thanks for the feedback. What I meant was adding a new event called OnTabChanging which fires before the tab has changed as opposed to OnTabChanged which fires after the tab has changed.

If you add this to the life cycle then should a user want to prevent a tab being changed they return false there. Means you can leave the current behaviour (ie not have to do work out how to change back to the original tab when you are on the new tab already in OnTabShow etc.)

ruionwriting commented 10 years ago

@VinceG what you think about pull request #69 ?

VinceG commented 10 years ago

@ruionwriting Sorry, haven't tested this yet. i'll try to do it this weekend.

accomazzo commented 10 years ago

Are there any plans on fixing this? I would love to keep using this with my project, and I would love to help fix it as well, but it's beyond my abilities.

69 doesn't seem to work for me either.

VinceG commented 10 years ago

@accomazzo did you test #69 and it didn't work for you either?

accomazzo commented 10 years ago

Yes that's correct, I even tried using bootstrap 3.0, I am using 3.1.

rubyconvict commented 10 years ago

'return false' does not work. On first tab get -1 index, then afrer clicking tab index gets cached, and on every first click on tab it has old index, on next clicks index is ok, but too late, so event if 'return false' would work, no glory.

Header navbar links are hard to disable, almost uncovered subject in the library.

David-Melo commented 9 years ago

Just in case anybody else runs into this like I did.

Using a combination of onTabClick and onNext I was able to prevent navigating based on validation

digEmAll commented 9 years ago

@David-Melo : could please create a jsfiddle example ? You can modify this if you like: http://jsfiddle.net/157ttz1p/2/

David-Melo commented 9 years ago

@digEmAll http://jsfiddle.net/157ttz1p/4/

Here you go, basically I wired every tabchange method to a validator function and pass in the current wizard tab. If the validation for that tab hasn't been met, then navigation is prevented. Hope this helps.

digEmAll commented 9 years ago

@David-Melo thanks a lot :)

siliconalchemy commented 8 years ago

Using the latest code, returning false for onTabClick doesn't work: onTabClick: function(tab, navigation, index) { return false; } It doesn't seem possible to disable tab clicks, which is a problem.

4pr3x commented 8 years ago

onTabClick: function(tab, navigation, index) { return false; } Is working for me! Only issue I have with onTabClick function is, that my "prev" & "next" button´s CSS is for some reason changed.

gayan-hewage commented 8 years ago

Wizard with disabled tab click not working?

http://vadimg.com/twitter-bootstrap-wizard-example/examples/basic-disabletabshow.html

any clue how to fix this?

VinceG commented 8 years ago

@gayanc can you try this:

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

keremcankaya0 commented 7 years ago

After an hour of struggle removing data-toggle=tab from the nav actually worked