Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // provide a shorter version to listen for events (like jQuery) but with a $-prefix
- // so it won't conflict with the builtin click() submit() etc.
- // $(element).$click(function() { ... });
- (function() {
- // Alias events to work directly as methods on elments
- var methods = {};
- $w("blur focus load resize scroll unload click dblclick ready" +
- "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
- "change select submit keydown keypress keyup error").each(function(eventName) {
- methods['$' + eventName] = function(element, handler) {
- return Event.observe(element, eventName, handler);
- }
- });
- Element.addMethods(methods);
- // alias $(document).ready for dom:loaded: $(document).ready(function() { ... });
- Object.extend(document, {
- ready: Event.observe.curry(document, 'dom:loaded')
- });
- })();
Add Comment
Please, Sign In to add comment