andy.kriger-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Jul-09 11:59 UTC
Firing native events
I saw this discussion about how native events cannot be fired by
Element.fire and how that could be solved with a custom-event proxy
http://groups.google.com/group/rubyonrails-spinoffs/browse_thread/thread/1facda5a22418beb/cce2efcecb42bb6e?lnk=gst&q=observe+native+event#cce2efcecb42bb6e
Can any of you more experienced Prototype/JavaScript coders give me
feedback on this solution? It adds a method to Element that lets me
register for native events and automatically create a proxy. Are there
any sideeffects I''m not aware of to doing this? (I''m an
experienced
Java coder, but very new to JavaScript and the dynamic prototype-style
of coding).
Element.addMethods({
createObserverProxy:function(ele,evt,proxy_evt,handler) {
ele.observe(evt,function(){this.fire(proxy_evt)},false);
if(handler instanceof Array) {
for(var i = 0; i <handler.length; i++) {
ele.observe(proxy_evt,handler,false);
}
} else {
ele.observe(proxy_evt,handler,false);
}
}
});
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---
Hi, We''ve started transitioning to a new, better-named, hopefully-spam- free group for Prototype and script.aculo.us: http://groups.google.com/group/prototype-scriptaculous/ prototype-scriptaculous-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Could you please post your question there instead? Thanks! People might still answer here, but probably not for all that much longer... -- T.J. Crowder tj / crowder software / com On Jul 9, 12:59 pm, "andy.kri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <andy.kri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I saw this discussion about how native events cannot be fired by > Element.fire and how that could be solved with a custom-event proxyhttp://groups.google.com/group/rubyonrails-spinoffs/browse_thread/thr... > > Can any of you more experienced Prototype/JavaScript coders give me > feedback on this solution? It adds a method to Element that lets me > register for native events and automatically create a proxy. Are there > any sideeffects I''m not aware of to doing this? (I''m an experienced > Java coder, but very new to JavaScript and the dynamic prototype-style > of coding). > > Element.addMethods({ > createObserverProxy:function(ele,evt,proxy_evt,handler) { > ele.observe(evt,function(){this.fire(proxy_evt)},false); > if(handler instanceof Array) { > for(var i = 0; i <handler.length; i++) { > ele.observe(proxy_evt,handler,false); > } > } else { > ele.observe(proxy_evt,handler,false); > } > } > });--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
andy.kriger-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Jul-09 12:07 UTC
Re: Firing native events
Done. Thank you for the heads-up. On Jul 9, 8:01 am, "T.J. Crowder" <t...-MUGVhKWuB3Yd9SLi6J12IkEOCMrvLtNR@public.gmane.org> wrote:> Hi, > > We''ve started transitioning to a new, better-named, hopefully-spam- > free group for Prototype and script.aculo.us: > > http://groups.google.com/group/prototype-scriptaculous/ > > prototype-scriptaculous-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > > Could you please post your question there instead? Thanks! People > might still answer here, but probably not for all that much longer... > -- > T.J. Crowder > tj / crowder software / com > > On Jul 9, 12:59 pm, "andy.kri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <andy.kri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > I saw this discussion about how native events cannot be fired by > > Element.fire and how that could be solved with a custom-event proxyhttp://groups.google.com/group/rubyonrails-spinoffs/browse_thread/thr... > > > Can any of you more experienced Prototype/JavaScript coders give me > > feedback on this solution? It adds a method to Element that lets me > > register for native events and automatically create a proxy. Are there > > any sideeffects I''m not aware of to doing this? (I''m an experienced > > Java coder, but very new to JavaScript and the dynamic prototype-style > > of coding). > > > Element.addMethods({ > > createObserverProxy:function(ele,evt,proxy_evt,handler) { > > ele.observe(evt,function(){this.fire(proxy_evt)},false); > > if(handler instanceof Array) { > > for(var i = 0; i <handler.length; i++) { > > ele.observe(proxy_evt,handler,false); > > } > > } else { > > ele.observe(proxy_evt,handler,false); > > } > > } > > });--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---