supongamos que tengo una función:En javascript, ¿cómo puedo llamar a un método de prototipo en otro método prototipo?
function test(){}
test.prototype.method01=function(){
//do something
}
test.prototype.method02=function(){
//how can I call the method01?
//this.method01()...?
//but the chrome through an error:
//Uncaught TypeError: Object #<HTMLImageElement> has no method 'method01'
}
Editado: de hecho el method01 así:
test.prototype.method02=function(){
$('.cpy').resizable({
}).draggable({
start:function(e,ui){
this.method01();
}
});
}
¿Está asignando 'method02' a un evento de una imagen por casualidad? – pimvdb
Depende de * cómo * llamas a 'method02'. Debería leer el [artículo de MDN sobre 'this'] (https://developer.mozilla.org/en/JavaScript/Reference/Operators/this). –
@pimvdb: He mejorado mi pregunta, muestro cómo lo llamo – hh54188