跳过stepy jQuery插件中的隐藏步骤

时间:2013-09-08 21:05:22

标签: javascript jquery jquery-plugins

我需要跳过stepy plugin中的一个步骤,但不知道该怎么做。我正在使用回调但不起作用,这是我的代码:

    next: function(index) {
        console.log(index);
        if ($('#product_create-head-2').is(':hidden')) {
            $('#product_create').find('fieldset').eq(2).hide();
            $('#product_create').find('fieldset').eq(3).show();
            $('#product_create').stepy('step', 3);
        }
    },
    back: function(index) {
        console.log(index);
        if ($('#product_create-head-2').is(':hidden')) {
            $('#product_create').find('fieldset').eq(2).hide();
            $('#product_create').find('fieldset').eq(1).show();
            $('#product_create').stepy('step', 1);
        }
    }

默认情况下$('#product_create-head-2')是隐藏的,但可以通过用户交互显示,所以当我按下一个/上一个时它隐藏了它应该跳过这个步骤并转到下一个/上一个,具体取决于用户操作,我正在做什么错?

1 个答案:

答案 0 :(得分:1)

你可以在这样的代码中使用stepy的“select”功能:

next: function(step){  // invoked by next button
          wzDir = 'fw'; //set direction forward
      },
back: function(step){  // invoked by back button
          wzDir = 'bw'; //set direction backward  
      },
select: function(step){
          if (step == 2){ //invoked on every selected step
            switch (wzDir){
              case 'fw': $('#product_create').stepy('step', 3); //jump to 3 
                         break; 
              case 'bw': $('#product_create').stepy('step', 1); //jump to 1
                         break; 
            }
          }
      }

这必须有效......