Jean-Philippe Encausse
2006-Oct-18 09:10 UTC
Bug Update from scriptaculous/prototype 1.6.1 to 1.6.4 Help ?
Hi, I migrate from Scriptaculous 1.6.1 to 1.6.4 and I think I have a bug with a new behavior of prototype on function bindAsEventListener(). Prototype has been updated from rc0 to rc1. In my code I do: $$(...).each(function(elm,idx){ elm.myvar = this; elm.onclick = this.myfunction.bindAsEventListener(elm); }.bind(this)); In myfunction() when I try to access to "myvar" it is undefined. - Any idea ? - Is there a list of changes or things to do for version update? Best regards -- Jean-Philippe Encausse Jp [at] encausse.net - http://www.encausse.com - http://www.jalias.com GTalk: jp.encausse [at] gmail.com - SMS: sms [at] jp.encausse.net Mob: +33 6 82 12 56 99 Jalios: +33 1 39 23 92 83 Tel: +33 1 39 18 90 15 Do it Once, Use it Twice ~ Do it Twice, Make It Once --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Chris Lear
2006-Oct-18 09:35 UTC
Re: Bug Update from scriptaculous/prototype 1.6.1 to 1.6.4 Help ?
* Jean-Philippe Encausse wrote (18/10/06 10:10):> Hi, > > I migrate from Scriptaculous 1.6.1 to 1.6.4 and I think I have a bug > with a new behavior of prototype on function bindAsEventListener(). > Prototype has been updated from rc0 to rc1. > > In my code I do: > > $$(...).each(function(elm,idx){ > elm.myvar = this; > elm.onclick = this.myfunction.bindAsEventListener(elm); > }.bind(this)); > > In myfunction() when I try to access to "myvar" it is undefined. > > - Any idea ? > - Is there a list of changes or things to do for version update?How are you accessing myvar? Reading your code (and guessing a bit, because I don''t know what "this" refers to in the first place), I would say that if myfunction looked like this: myfunction=function() { alert(this.myvar); } It should display "Object [Object]" when clicked. But it''s tricky to be sure, because you''ve got a lot of binds and this''s in there. Did exactly the same code work before the prototype upgrade? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Jean-Philippe Encausse
2006-Oct-18 10:13 UTC
Re: Bug Update from scriptaculous/prototype 1.6.1 to 1.6.4 Help ?
I found the solution ! In fact I was using the function "myfunction(event, arg1, arg2, arg3)" directly and with "bindAsEventListener" The bindAsEventListener is calling myfunction() always with 2 parameters now: myfunction(event, args) so I have to update all my function call to do: myfunction(event, args, arg1,arg2,arg3) On 10/18/06, Jean-Philippe Encausse <Jp-vcK5r0oTKUrk1uMJSBkQmQ@public.gmane.org> wrote:> Hi, > > I migrate from Scriptaculous 1.6.1 to 1.6.4 and I think I have a bug > with a new behavior of prototype on function bindAsEventListener(). > Prototype has been updated from rc0 to rc1. > > In my code I do: > > $$(...).each(function(elm,idx){ > elm.myvar = this; > elm.onclick = this.myfunction.bindAsEventListener(elm); > }.bind(this)); > > In myfunction() when I try to access to "myvar" it is undefined. > > - Any idea ? > - Is there a list of changes or things to do for version update? > > Best regards > > -- > Jean-Philippe Encausse > Jp [at] encausse.net - http://www.encausse.com - http://www.jalias.com > GTalk: jp.encausse [at] gmail.com - SMS: sms [at] jp.encausse.net > Mob: +33 6 82 12 56 99 Jalios: +33 1 39 23 92 83 Tel: +33 1 39 18 90 15 > Do it Once, Use it Twice ~ Do it Twice, Make It Once >-- Jean-Philippe Encausse - R&D Jalios SA Jp [at] encausse.net - http://www.encausse.com - http://www.jalias.com GTalk: jp.encausse [at] gmail.com - SMS: sms [at] jp.encausse.net Mob: +33 6 82 12 56 99 Jalios: +33 1 39 23 92 83 Tel: +33 1 39 18 90 15 Do it Once, Use it Twice ~ Do it Twice, Make It Once --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Jean-Philippe Encausse
2006-Oct-18 10:38 UTC
Re: Bug Update from scriptaculous/prototype 1.6.1 to 1.6.4 Help ?
I agree the code is a littlebit a shortucto the original code. "this" set in myvar refere to the object executing $$ code Yes it worked before. - Before myfunction() was called only with myfunction(event) - Now myfunction() is called with myfunction(event, args) Thats why my code broke because before I was calling somewhere else myfunction(event, myarg1, myarg2) On 10/18/06, Chris Lear <chris.lear-kZMsvDh4tCZWk0Htik3J/w@public.gmane.org> wrote:> > * Jean-Philippe Encausse wrote (18/10/06 10:10): > > Hi, > > > > I migrate from Scriptaculous 1.6.1 to 1.6.4 and I think I have a bug > > with a new behavior of prototype on function bindAsEventListener(). > > Prototype has been updated from rc0 to rc1. > > > > In my code I do: > > > > $$(...).each(function(elm,idx){ > > elm.myvar = this; > > elm.onclick = this.myfunction.bindAsEventListener(elm); > > }.bind(this)); > > > > In myfunction() when I try to access to "myvar" it is undefined. > > > > - Any idea ? > > - Is there a list of changes or things to do for version update? > > How are you accessing myvar? > > Reading your code (and guessing a bit, because I don''t know what "this" > refers to in the first place), I would say that if myfunction looked > like this: > > myfunction=function() { > alert(this.myvar); > } > > It should display "Object [Object]" when clicked. > > But it''s tricky to be sure, because you''ve got a lot of binds and this''s > in there. > > Did exactly the same code work before the prototype upgrade? >-- Jean-Philippe Encausse - R&D Jalios SA Jp [at] encausse.net - http://www.encausse.com - http://www.jalias.com GTalk: jp.encausse [at] gmail.com - SMS: sms [at] jp.encausse.net Mob: +33 6 82 12 56 99 Jalios: +33 1 39 23 92 83 Tel: +33 1 39 18 90 15 Do it Once, Use it Twice ~ Do it Twice, Make It Once --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve
2006-Oct-18 20:11 UTC
Re: Bug Update from scriptaculous/prototype 1.6.1 to 1.6.4 Help ?
Jean-Philippe Encausse a écrit :> In myfunction() when I try to access to "myvar" it is undefined. > > - Any idea ?Are you actually accessing "this.myvar"?> - Is there a list of changes or things to do for version update?Sure, the changelog is there, my friend: http://dev.rubyonrails.org/browser/spinoffs/prototype/CHANGELOG -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---