Kod
function Class() {
this.foo1=1;
this.foo2=2;
this.Init=function() {
// create HTML and append to DOM here
this.AddListeners();
}
this.AddListeners=function() {
$('get existing element right').click() {
console.log('test');
this.DoSome(); //
!
}
}
this.DoSome=function() {
console.log(this.foo2);
}
}
var object=new Class();
object.Init();
this.foo1=1;
this.foo2=2;
this.Init=function() {
// create HTML and append to DOM here
this.AddListeners();
}
this.AddListeners=function() {
$('get existing element right').click() {
console.log('test');
this.DoSome(); //

}
}
this.DoSome=function() {
console.log(this.foo2);
}
}
var object=new Class();
object.Init();
Oczywiśćie funkcja DoSome() nie jest wywoływana. Na wyjściu konsoli wypisuje się 'test' więc skrypt wchodzi do .click(){} ale nie widzi funkcjki DoSome().. Domyślam się że jest to związane z przestrzeniami nazw. Ale za Chiny ludowe nie potrafię sobie z tym poradzić. Ktoś wie jak obejść ten problem ?