jQuery Events
This MooTools code snippet allows you to use shorthand, jQuery-style Event syntax.
Download @ Forge JS
MooTools Javascript Class
/*
---
description: jQueryEvents
authors:
- David Walsh (http://davidwalsh.name)
license:
- MIT-style license
requires:
core/1.2.1: '*'
provides:
- Element.click
- Element.mouseenter
- (etc.)
...
*/
//hash the element.natives so we can do stuff with it
var hash = new Hash(Element.NativeEvents);
//remove items that need to be replaced, add their replacements
hash.erase('mouseover').erase('mouseout').erase('DOMMouseScroll');
hash.include('mouseenter',1).include('mouseleave',1);
//initialize this
var eventHash = new Hash({});
//for every event type, add to our hash
hash.getKeys().each(function(event){
eventHash[event] = function(fn) {
this.addEvent(event,fn);
return this;
};
});
//make it happen
Element.implement(eventHash);jQueryEvents
This MooTools code snippet allows you to use shorthand, jQuery-style Event syntax.
How to Use
All you need to do is add the jQueryEvents.js file into the page. A few sample usages are:
Javascript
$('myElement').click(function() {
//do stuff
});
window.scroll(function() {
//do stuff
});
For specific usage and options, please read the documentation or visit http://davidwalsh.name/js/jqueryevents