I have some code that creates several observers for elements on a
page. Due to my application logic, those elements may or may not be
there. So I was wrapping them in conditional logic. To make that logic
easier I implemented the following:
Object.extend(Event, {
observe_if_present: function(element,eventName,handler) {
Object.isElement(element) ?
Event.observe(element,eventName,handler) : false
}
})
First of all, is this a good idea? Is there a better way to initialize
observers for elements that may or may not exist?
Thanks,
Matt
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---