I don't understand how to pass a variable from the init function to the bindEvent function in my object: At the moment, I get undefined.
var Fisheye = {
init: function () {
$('body').hide();
$(window).load(function() {
$('body').fadeIn('slow');
this.imgs = $('.pic').children('img');
this.originalWidth = $(imgs).first().css('width');
this.minWidth = 300;
imgs.width(300);
Fisheye.bindEvents();
});
},
bindEvents: function() {
$(this.imgs).toggle(this.toggleClick, this.toggleClick);
console.log(this.imgs); // Why do I get Undefined here?
},
toggleClick: function() {
//Todo
}
}
Fisheye.init();
How to properly pass a variable from a function to another in an object?
Thanks!