Следующий код:Confusment с 'этой области видимости
define(function() {
var Module = function() {
$('.fixed-sidebar').each(function(index) {
FixedSidebar.apply(this);
});
}
var FixedSidebar = function() {
var me = this;
this.hiddenStatus = true;
console.log (this.toggle);
$($(this).find('.fixed-handler')).on('click', function() {
console.log('event passed');
//me.toggle();
//console.log (this);
});
}
FixedSidebar.prototype = {
constructor : FixedSidebar
,toggle : function() {
if(this.hiddenStatus) {
this.hiddenStatus = false;
$('.fixed-sidebar').animate({
left: '-300px'
}, 1000);
} else {
this.hiddenStatus = true;
$('.fixed-sidebar').animate({
left: '0px'
}, 1000);
}
}
};
return Module;
});
любая идея, почему JavaScript не прототипирования метод «тумблер» в следующий момент?
console.log (this.toggle); // undefined
пожалуйста, определить, 'определение' – loxxy
определения –
модуля requirejs 'define' является функция, где определяется? –