top.on('click', function(){
anim.run();
});
J'ai une fonction anim, et je me demandais pourquoi je ne peux pas appeler comme çaYUI3 appelant dans le second cas une fonction
top.on('click', anim.run);
top.on('click', function(){
anim.run();
});
J'ai une fonction anim, et je me demandais pourquoi je ne peux pas appeler comme çaYUI3 appelant dans le second cas une fonction
top.on('click', anim.run);
top.on('click', function() { anim.run(); });
ou
top.on('click', Y.bind(anim.run, anim));
Parce que this
n'est pas anim
que vous récupérez la run
fonction et ne l'appelant pas de anim
.
Par exemple:
var a = {
b: function() {
return this.c;
},
c: 1
},
c = 2;
a.b() === 1;
var bMethod = a.b;
bMethod() === 2;
ok, donc top.on (clic, parent.anim.run); fonctionne merci – Daniel
Non, sauf si 'run' ne fait pas référence' this'. –
Merci, bon de voir un membre de l'équipe YUI! – Daniel