Your french is perfect, and your reply too! Thank you!
On 7 avr, 13:35, "T.J. Crowder" <[email protected]> wrote: > Hi, > > Every time you call `bind`, a *new* function is created. To remove an > event listener, you have to give `removeEventListener` a reference to > the *same function* that you gave `addEventListener`. > > (Chaque fois que vous appelez `bind`, une *nouvelle* fonction est > créée. Pour supprimer un écouteur d'événement, vous devez donner > `removeEventListener` une référence à *la même fonction* que vous avez > donné `addEventListener`.) > > Separately, unless you're using Prototype 1.5 or earlier, you don't > want to replace the prototype of the function you get back from > `Class.create`. Instead, pass in the properties you want the prototype > to have. > > (Par ailleurs, sauf si vous utilisez Prototype 1.5 ou antérieure, vous > ne voulez pas de remplacer le prototype de la fonction de votre retour > du `Class.create`. Au lieu de cela, passer dans les propriétés que > vous voulez le prototype d'avoir.) > > Your `callThisMethod` was also unnecessary (that's what the function > `bind` does for you). > > (Votre `callThisMethod` était aussi inutile [c'est ce que la fonction > `bind` fait pour vous].) > > So (si): > > var essai = Class.create({ > initialize : function(texte){ > this.texte = texte; > // Create the function once, and remember it > // (Créer la fonction une fois, et s'en souviennent) > this.boundThisMethod = this.thisMethod.bind(this); > // Use it when adding > // (Utilisez-le lors de l'ajout) > > document.addEventListener("click",this.boundThisMethod,false); > }, > thisMethod : function(){ > alert(this.texte); > // Use that same one when removing > // (Utilisez celui-là même lorsque vous retirez) > > document.removeEventListener("click",this.boundThisMethod,false); > } > > }); > > French translations courtesy of translate.google.com, apologies for > any errors. > > (Traductions en français avec la permission de translate.google.com, > excuses pour les erreurs.) > > HTH, > -- > T.J. Crowder > Independent Software Engineer > tj / crowder software / com > www / crowder software / com > > On Apr 7, 12:01 pm, alexflex25 <[email protected]> wrote: > > > Hi > > > I d'ont understand why this code don't work properly. > > > var essai = Class.create(); > > essai.prototype = { > > initialize : function(texte){ > > this.texte = texte; > > > document.addEventListener("click",this.callThisMethod.bind(this),false); > > > > document.addEventListener("click",OtherSimpleFunction,false); > > }, > > callThisMethod : function(){ > > this.ThisMethod(); > > }, > > ThisMethod : function(){ > > alert(this.texte); > > //Le problème se trouve donc ICI, juste là... > > //Pourquoi la ligne ci-dessous ne fonctionne pas > > > document.removeEventListener("click",this.callThisMethod.bind(this),false); > > } > > > } > > > function OtherSimpleFunction(){ > > alert('Hello, Just One Time'); > > document.removeEventListener("click",OtherSimpleFunction,false); > > > } > > > var a = new essai('Hello, Forever ... Grrrrr'); > > > Why he say "Hello, Forever ... Grrrrr" forever forever forever.... > > Sorry about my english .... -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
