Skip to content

Commit f22dfb7

Browse files
committed
fixes deferred object to allow for async check along with validation
1 parent 4e1078b commit f22dfb7

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

src/defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ var defaults = $.fn.steps.defaults = {
100100
stepsOrientation: stepsOrientation.horizontal,
101101

102102
/*
103-
* Tempplates
103+
* Templates
104104
*/
105105

106106
/**

src/privates.js

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -440,25 +440,30 @@ function goToStep(wizard, options, state, index)
440440
}
441441

442442
var oldIndex = state.currentIndex;
443-
if (wizard.triggerHandler("stepChanging", [state.currentIndex, index]))
444-
{
445-
// Save new state
446-
state.currentIndex = index;
447-
saveCurrentStateToCookie(wizard, options, state);
448-
449-
// Change visualisation
450-
refreshStepNavigation(wizard, options, state, oldIndex);
451-
refreshPagination(wizard, options, state);
452-
loadAsyncContent(wizard, options, state);
453-
startTransitionEffect(wizard, options, state, index, oldIndex, function()
454-
{
443+
//
444+
var ajax = wizard.triggerHandler("stepChanging", [state.currentIndex, index]);
445+
446+
jQuery.when(ajax)
447+
.done(function(status) {
448+
if (status !== false) {
449+
// Save new state
450+
state.currentIndex = index;
451+
saveCurrentStateToCookie(wizard, options, state);
452+
453+
// Change visualisation
454+
refreshStepNavigation(wizard, options, state, oldIndex);
455+
refreshPagination(wizard, options, state);
456+
loadAsyncContent(wizard, options, state);
457+
startTransitionEffect(wizard, options, state, index, oldIndex, function() {
455458
wizard.triggerHandler("stepChanged", [index, oldIndex]);
456-
});
457-
}
458-
else
459-
{
459+
});
460+
} else {
461+
wizard.find(".steps li").eq(oldIndex).addClass("error");
462+
}
463+
})
464+
.fail(function() {
460465
wizard.find(".steps li").eq(oldIndex).addClass("error");
461-
}
466+
});
462467

463468
return true;
464469
}

0 commit comments

Comments
 (0)