The code is pretty straight foreword:
var handleNextPressedDeferred = $.Deferred();
$('input:button').live('click',function(){
console.log('resolving');
return handleNextPressedDeferred.resolve();
});
handleNextPressedDeferred.pipe(function(){
console.log('rejecting');
return $.Deferred().reject();
});
var handleNextPressedPromise = handleNextPressedDeferred.promise();
handleNextPressedPromise.done(function(){
console.log('done');
});
handleNextPressedPromise.then(function(){
console.log('then');
});
handleNextPressedPromise.fail(function(){
console.log('fail');
});
After the original button click resolves the deferred, I'm interested in rejecting it by the piped function.
The expected outcome when the button is clicked is:
- resolving
- rejecting
- fail
The actual outcome when the button is clicked is:
- resolving
- rejecting
- done
- then
What am I not understanding correctly here? I've tried a million variations of this and couldn't get it to work as expected.