I'm having problems waiting for a deferred to complete when using the deferred in the onStepChanging
event on the jQuery plugin "jQuery-Steps". This plugin is documented at http://www.jquery-steps.com/. The step returns immediately instead of waiting for the deferred. In my real code I am doing an ajax call and I want to wait for the result before proceeding to the next step.
Here is some sample code:
$(document).ready(function() {
var form = $("#form1");
form.children("div").steps({
headerTag: "h3",
bodyTag: "section",
transitionEffect: "slideLeft",
onStepChanging: function(event, currentIndex, newIndex) {
$.when(asyncEvent()).then(function(status) {
return status;
});
}
});
});
function asyncEvent() {
var dfd = new $.Deferred();
setTimeout(function() {
dfd.resolve(true);
}, 2000);
return dfd.promise();
}
Any help is greatly appreciated!