Q:

jQuery promise with dependent promise and overall completion

Lets say i have 2 promises promise1, promise2 that go off and do something asynchronously. 
promise2 depends on promise1 being done before running itself.  This is easy enough. 
function runPromises(){
    return promise1().done(function(){
       promise2();
    });
}

The problem is i also want to know when they have both finished. 
runPromises().done(function(){
   alert("promise 1 and 2 done");
});

currently runPromises is alerting when promise1 is done not both. 

A:

To chain promise actions, and get a promise for the second result (i.e. when both are done), use the then method instead of  done:
function runPromises(){
    return promise1().then(function(){
//                    ^^^^
        return promise2();
//      ^^^^^^ always return promise from async functions like this callback
    });
}

You might even shorten this to return promise1().then(promise2); if you don't care about the arguments.