javascript - this inside callback function -


this question has answer here:

here situation.

function bird() {   this._canfly = true;   this._legs = 2;   this._flying = false; }  bird.prototype = {   fly: function() {     if ( this.canfly ) {         layer.on('fly', function() {            this.setstrokewidth(4); //this refers layer(kinetic.js) object            this._flying = true; //this refers bird object         });     }//end if   } //end function ); 

here need access both layer object , bird object inside callback function. can tell me how handle above situation ?

var self = 

cache reference this refer when changes context.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -