• Stars
    star
    492
  • Rank 86,026 (Top 2 %)
  • Language
    JavaScript
  • Created over 11 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Event delegation in Javascript

Gator

Gator is a Javascript event delegation library.

It is around 800 bytes when gzipped and minified and has no external dependencies.

Browser Support

Out of the box Gator works in

  • Chrome
  • Safari 5+
  • Firefox 3.6+
  • Internet Explorer 9+

The legacy.js plugin adds support for

  • Safari < 5
  • Firefox < 3.6
  • Internet Explorer 6, 7, 8

When using the legacy plugin only single classes, single ids, and single tag names are supported for selectors

Getting Started

  1. Include gator on your page before the closing </body> tag

    <script src="/path/to/gator.min.js"></script>
  2. Add some events

    <script>
        // add a click event to document that checks for elements with class expand
        Gator(document).on('click', '.expand', function(e) {
            console.log('clicked on', this);
            return false;
        });
    
        // add a click event to document with no delegation
        Gator(document).on('click', function() {
            console.log('clicked on document!');
        });
    
        // remove all click events on .expand
        Gator(document).off('click', '.expand');
    
        // remove all click events on document
        Gator(document).off('click');
    </script>

Documentation

Full documentation is available at http://craig.is/riding/gators

More Repositories

1

mousetrap

Simple library for handling keyboard shortcuts in Javascript
JavaScript
11,569
star
2

rainbow

Simple syntax highlighting library written in javascript
JavaScript
3,294
star
3

chromephp

class for logging PHP variables to Google Chrome console
PHP
1,376
star
4

chromelogger

chrome extension for server side console logging
JavaScript
897
star
5

chromelogger-python

Python library for logging variables to Google Chrome console
Python
232
star
6

html-muncher

renames classes and ids in your css, javascript, and html to save bytes and obfuscate your code
Python
175
star
7

luna-testing

Simple, modern, opinionated JavaScript unit testing
JavaScript
151
star
8

mmlx

NES chiptune programming language
Python
85
star
9

sonic

fast, lightweight PHP 5.3 MVC framework
PHP
62
star
10

xtab

Chrome extension for limiting the total number of tabs you can have open at the same time
JavaScript
58
star
11

sublime-goto-window

Sublime Text plugin to quickly switch to any open window using a keyboard command
Python
41
star
12

nijikodo

Code syntax highlighting library written in PHP.
PHP
29
star
13

sublime-jsx

Simple Sublime Text 3 JSX implementation
25
star
14

sublime-smart-match

Sublime Text package to make parenthesis, bracket, and square bracket completions smarter
Python
17
star
15

aftershave

Compiled javascript templates
JavaScript
15
star
16

cloud-storage

Simple node js module for uploading and removing files from Google Cloud Storage
JavaScript
12
star
17

storm

Simple ORM for Tornado
Python
8
star
18

octopus

Simple asynchronous helpers
JavaScript
7
star
19

sonic-extensions

repository of official extensions for sonic framework
PHP
5
star
20

clapp

Command line app builder for go
Go
4
star
21

shift-voter-analysis

Script to analyze shift voting algorithms
JavaScript
1
star
22

show-missing-revs

Shows subversion revisions that have not been merged from one branch to another.
Shell
1
star