Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

How to return true after function is comopleted?

$
0
0

i know its elementary javascript question but still it'll be of great help. i'm stuck in following function:

Utils.get = function (action,index,callback){
    var books  = Alloy.createCollection('books');
    books.fetch({success: function(){  
        var authors  = Alloy.createCollection('authors');
        authors.fetch({success: function(){ 
            callback();
        },});
    },});
};
in above function i'm using restsql.js so both fetch need to be done "remotely". i could return true, but i'm using callback.

PROBLEM : above function returns callback 2 times. i just need to RETURN ONCE after both fetch are done.

(return true also returns twice...) is there any way that after both fetch are done, function returns callback only once?


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>