supponiamo Ho una funzione:In javascript, come posso chiamare un metodo prototipo in un altro metodo 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'
}
Modificato: infatti il method01 in questo modo:
test.prototype.method02=function(){
$('.cpy').resizable({
}).draggable({
start:function(e,ui){
this.method01();
}
});
}
Stai assegnando 'method02' ad un evento di un'immagine per caso? – pimvdb
Dipende da * come * si chiama 'method02'. Dovresti leggere l'articolo [MDN su 'this'] (https://developer.mozilla.org/en/JavaScript/Reference/Operators/this). –
@pimvdb: Ho migliorato la mia domanda, mostra come la chiamo – hh54188