jQuery.when()
is available through the application object as this.when()
. Here is a simple example (version 0.5 framework) that creates a couple of trivial promises (using this.promise()
, similar to jQuery.Deferred()
), then waits until they succeed / are allowed to call the third function.
Replace this.ajax(...)
with this.createPromise()
to do the real work.
app.js
(function() { return { onActivate: function() { var promises = [] promises.push(this.createPromise().done(function() { console.log('promise 1 done'); })); promises.push(this.createPromise().done(function() { console.log('promise 2 done'); })); this.when.apply(this, promises).done(function() { console.log('all promises done'); }); },
source share