Skip to content

Instantly share code, notes, and snippets.

@nesquena
Created October 14, 2008 00:21
Show Gist options
  • Save nesquena/16631 to your computer and use it in GitHub Desktop.
Save nesquena/16631 to your computer and use it in GitHub Desktop.
# example of my desired syntax for behaviors in red
# /public/javascripts/red/example.red
class ExampleBehavior < Behavior
def initialize(options={})
self.something = 5
end
def on_click(event)
self.element.hide
# ... more stuff
end
def on_mouseover(event)
self.element.set_style(:background_color, 'red')
end
def on_mouseout(event)
self.element.set_style(:background_color, 'gray')
end
end
document.bind('ready') do
document.select('div.example').apply(ExampleBehavior)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment