jquery-steps icon indicating copy to clipboard operation
jquery-steps copied to clipboard

How to check with ajax?

Open niels-numbers opened this issue 4 years ago • 0 comments

This seems to be a duplicate of #234 but I don't understand the solution there.

When I call onStepChanging then an external api call is made (whenValidate returns a jquery promise). For synchronize calls this method works because I can just return true/false, but what do I have to do when I have a asynchronous call?

 $(".steps-validation").steps({
        headerTag: "h6",
        bodyTag: "fieldset",
        transitionEffect: "fade",
        titleTemplate: '<span class="number">#index#</span> #title#',
        autoFocus: true,
        enableFinishButton: false,
        onStepChanging: function (event, currentIndex, newIndex) {

            // Allways allow previous action even if the current form is not valid!
            if (currentIndex > newIndex) {
                return true;
            }
           
            var validateForm = form.parsley().whenValidate({
                group: 'block-' + currentIndex
            });
            
            validateForm.then(function () { 
                  // CONTINUE HERE WITH NEXT STEP
                  $("#wizard").steps("next",{}); 
            

            }, function () { console.log('oh no..');});

niels-numbers avatar Feb 16 '21 21:02 niels-numbers