scope - Javascript Object Function Scoping -


let's have class:

var asdf = new class({   myfunction: function () {     //some stuff here   },   anotherfunction: function() {     globalobject.dosomethingandusecallback(        function() { // callback         //how call myfunction() here? can't seem work?       }     );   } }); 

i seem have scoping problems in trying call myfunction within definition of callback function. missing here? thought should have access myfunction in context?

thanks!

copy this keyword variable outside of callback function, , use variable inside callback:

anotherfunction: function() {   var self = this;   globalobject.dosomethingandusecallback(      function() { // callback       self.myfunction();     }   ); } 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -