i'm trying figure out how access variable inside .when.done function. here's example:
var colviews = { 1: true, 2: true, 3: false } $.when( // run -when- these script loaded $.getscript( "/mckinney_images/jquery.tablesorter.all.js" )).done(function(){ $(function(){ console.log(colviews); // how colviews variable here? }); }); i have basic understanding of scope not sure how applies inside when function.
i have basic understanding of scope
good! know what scope is, how closures work , how var works.
…but not sure how applies inside when function.
simple: it's no different! yes, done callback function invoked asynchronously, doesn't change how scope works.
are getting colviews variable there (if doesn't log expected value, means overwritten elsewhere or callback never called because $.getscript failed).
$.when no magic (and in fact, in example it's not needed @ all, code works same when omit it).
Comments
Post a Comment