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@googlegroups.com
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