sathomas / acc-wizard

Wizard implementation for bootstrap based on accordion
216 stars 76 forks source link

Adding hooks for 'beforeNext' and 'beforeBack' #9

Closed clocklear closed 11 years ago

clocklear commented 11 years ago

I've added support to your library for 'beforeNext' and 'beforeBack' hooks. This will allow input validation before the user continues to the next step (or backtracks to a previous step).

smithdp1 commented 10 years ago

clocklear can you please show example of using beforeNext for validation?

clocklear commented 10 years ago

Something like this:

$(window).load(function() {
  $(".acc-wizard").accwizard({
    onBeforeNext: function(panel) {
      // The thing that gets fired before you move 'forward'

      // do some validation....

      // return a FALSE here to prevent onNext from firing
      return false;
    },
    onNext: function(parent, panel) {
      // The thing that actually moves your wizard 'forward'
      hash = "#" + panel.id;
      $(".acc-wizard-sidebar",$(parent))
        .children("li")
        .children("a[href='" + hash + "']")
        .parent("li")
        .removeClass("acc-wizard-todo")
        .addClass("acc-wizard-completed");
    }
  });
});
smithdp1 commented 10 years ago

clocklear thank you so much for taking the time. This is a great example! I will try to put it to use today.

Thanks again!