On 12/16/06, RobG <[EMAIL PROTECTED]> wrote:
>
> Peter Michaux wrote:

> > So what is the syntax to do this?
> >
> > <pseudocode>
> >
> >   function attachMyObserver() {
> >      function handler(){}
> >      attach("myDiv", 'click', handler);
> >    }
> >
> >   attachMyObserver();
> >   detach('myDiv', 'click', handler);
> >
> > </pseudocode>
>
>
>   var fn = (function(){
>     function handler(){...}
>     return {
>       addHandler : function(el, eType){
>        attach(el, eType, handler);
>       },
>       delHandler : function(el, eType){
>        detach(el, eType, handler);
>       }
>     };
>   })();
>
>   fn.addHandler(...);
>   fn.delHandler(...);
>


Ok. If you want to cheat ;-) I was just trying to point out that
anonymous functions were not the only sticky situation and that named
inner functions require more care which you showed.

Peter

--~--~---------~--~----~------------~-------~--~----~
 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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to