javascript - Unable to access method in object literal -


in object literal should able access methods using this.name, in case below i'm using this.init() trigger method gave me undefined function instead. if refer alltabanimation.init() works, why ?

var alltabanimation = {     desktopclick: function (){         $('.allforms .investoroptions .investoroptions-wrapper .select-options input+label').click(function (e){             $this = $(this),             $thishooknumber  = $(this).data("hook"),             $alltab = $(".tab-content"),             $selectedtab  = $(".tab-content[data-hook="+$thishooknumber+"]"),             this.init(); // doesn't work             // alltabanimation.init(); // work         });     },  init: function (){     this.condition($selectedtab, $alltab); }, 

store this in variable (or use .bind, or $.proxy), because in case this refers element not parent object, so

var alltabanimation = {      desktopclick: function() {         var self = this;          $('.allforms .investoroptions .investoroptions-wrapper .select-options input+label').click(function(e) {              $this = $(this),                 $thishooknumber = $(this).data("hook"),                 $alltab = $(".tab-content"),                 $selectedtab = $(".tab-content[data-hook=" + $thishooknumber + "]")              self.init();         });     },      init: function() {         this.condition($selectedtab, $alltab);      } }