In object literal we should be able to access the methods using this.name
, but in my case below I'm using this.init()
to trigger a method but gave me undefined function instead. However if I refer to allTabAnimation.init()
it works, why is that ?
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(); // this work
});
},
init: function (){
this.condition($selectedTab, $allTab);
},