for some reason i can't seem to setup a deferred. Here s my setup
// some class
find: function () {
var deferred = $.Deferred();
Func.run(function (err, results) {
return results;
});
deferred.resolve(results);
return deferred.promise;
},
test: function () {
$.when(this.find()).done(function(data){
console.log(data);
});
}
im trying to call this.find()
but i want it to return a promise... the issue is that Func.run()
is async, so i need to wait until that is finished as well.
I'm also using backbone.js
, is there is a different way to do it there.
any ideas what is wrong with my code?