2

我在 FUELUX 上做了一些自定义向导,它可以显示在这个链接http://jsfiddle.net/L3b9E/2

问题是,我不知道如何在向导中的每一步修复表单验证并由选项卡分隔。因为验证不适用于第二个、第三个等选项卡。

任何想法..?

jQuery代码:

var $nextText;
$(document).on('click','[data-wizard]',function(e){
    var $this=$(this),href;
    var $target=$($this.attr('data-target')||(href=$this.attr('href'))&&href.replace(/.*(?=#[^\s]+$)/,''));
    var option=$this.data('wizard');
    var item=$target.wizard('selectedItem');
    var $step=$target.next().find('.step-pane:eq('+(item.step-1)+')');
    !$nextText&&($nextText=$('[data-wizard="next"]').html());
    var cek = 0, $data=[],$e=[],$v=[], $lokasi = $this.attr('lokasi'); //means path to save file

    if(option == "next"){
        $step.find(':input[data-required=true]').each(function(){
            $(this).jinForm('validate');
            if($(this).jinForm('isValid') != true){
                cek = 0;
            }else{
                cek = 1;
                $e.push($(this).attr('id'));
                $v.push($(this).val());

                $data.push($(this).serialize());
            }
        });
        alert($data);
    }

    if(cek == 0){
        return false;
    }else{
        $.post($lokasi,{e:$e,v:$v},function(hasil){ jin.alert(hasil);
            if(hasil==0){
                jin.alert("Saving Data, <b class='text-danger'>Error..!!!</b>");
                return false
            }else{
                $target.wizard(option);
                var activeStep=(option=="next")?(item.step+1):(item.step-1);
                var prev=($(this).hasClass('btn-prev')&&$(this))||$(this).prev();
                var next=($(this).hasClass('btn-next')&&$(this))||$(this).next();
                prev.attr('disabled',(activeStep==1)?true:false);
                next.html((activeStep<$target.find('li').length)?$nextText:next.data('last'));
            }
        }).error(function(){ jin.alert("Save Target Path is <b class='text-danger'>Not Exist</b>..!"); });
    }
});
4

1 回答 1

-1

这里讨论了一个类似的场景。它应该提供一些见解。如果不是,请为您的用例提供更多详细信息。

于 2014-11-07T22:11:30.547 回答