Skip to content

Instantly share code, notes, and snippets.

@nesquena
Created October 14, 2008 00:29
Show Gist options
  • Save nesquena/16636 to your computer and use it in GitHub Desktop.
Save nesquena/16636 to your computer and use it in GitHub Desktop.
// public/javascripts/example.js
ExampleBehavior = Behavior.create({
initialize : function() {
this.something = 5;
},
onclick : function() {
this.element.hide();
// ... more stuff
},
onmouseover : function() {
this.element.setStyle({ backgroundColor : 'red' })
},
onmouseout : function() {
this.element.setStyle({ backgroundColor : 'gray' })
}
})
document.observe('ready', function(){
Event.addBehavior({
'div.example' : ExampleBehavior
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment