hard to say because your example is so abstract. I mean, you're objective is to log "this" but you want to pass 1,2,3. yes, there are ways to do this, but it's clear this isn't a real world example. For instance, you could pass 1,2,3 and bind the element and get what you want. Or you can make 1,2,3 a variable that fn has access to...
2009/5/21 Fábio Costa (via Nabble) <ml-user+98816-1760363...@n2.nabble.com<ml-user%2b98816-1760363...@n2.nabble.com> > > Hmm i got it. > But is there a good way to do what im doing on my example? > > Fábio Miranda Costa > Engenheiro de Computação > http://meiocodigo.com > > > On Thu, May 21, 2009 at 4:53 PM, nutron > <anut...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2953913&i=0> > > wrote: > >> No, think about it. >> you create a function called fn. it's "this" by default is the window. >> >> addEvent automatically binds the element to the function you pass it. If >> you passed fn to it, "this" would be the element. >> >> BUT, you create a NEW function called clickFn. This function has no "this" >> bound to it. It essentially wraps fn within it. When you pass clickFn to >> addEvent, it's "this" is bound to the element, but not the function it >> wraps. "this" isn't handed down magically or automatically. You must be >> explicit. This is important, because what if you WANT fn bound to the >> window. You don't want .pass binding something else to your methods unless >> you tell it to. >> >> 2009/5/21 Fábio Costa (via Nabble) >> <ml-user%2b98816-1760363...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2953880&i=0> >> > >> >> I think the pass function is buggy. It is not binding the correct element >>> when there is nothing to bind. >>> >>> Lets say: >>> >>> var fn = function(){ >>> console.log(this); >>> }; >>> >>> var clickFn = fn.pass([1,2,3]); >>> >>> $('anchor').addEvent('click', clickFn); >>> >>> The console should show (IMO) the element with id=anchor, but it shows >>> the window element. >>> I know a patch for this but i wanna know from the core developers if this >>> is true or false before posting a ticket. >>> Cheers. >>> >>> Fábio Miranda Costa >>> Engenheiro de Computação >>> http://meiocodigo.com >>> >> >> The MooTools Tutorial: www.mootorial.com Clientcide: www.clientcide.com >> >> ------------------------------ >> View this message in context: Re: [Moo] pass() >> buggy<http://n2.nabble.com/-Moo--pass%28%29-buggy-tp2953850p2953880.html> >> Sent from the MooTools Users mailing list >> archive<http://n2.nabble.com/MooTools-Users-f660466.html>at Nabble.com. >> > > > > ------------------------------ > View message @ > http://n2.nabble.com/-Moo--pass%28%29-buggy-tp2953850p2953913.html > To start a new topic under MooTools Users, email > ml-node+660466-1583815...@n2.nabble.com<ml-node%2b660466-1583815...@n2.nabble.com> > To unsubscribe from MooTools Users, click here< (link removed) >. > > > ----- The MooTools Tutorial: http://www.mootorial.com www.mootorial.com Clientcide: http://www.clientcide.com www.clientcide.com -- View this message in context: http://n2.nabble.com/-Moo--pass%28%29-buggy-tp2953850p2954052.html Sent from the MooTools Users mailing list archive at Nabble.com.