GithubHelp home page GithubHelp logo

codeclown / gator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ccampbell/gator

0.0 3.0 1.0 51 KB

Event delegation in Javascript

Home Page: http://craig.is/riding/gators

JavaScript 100.00%

gator's Introduction

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

gator's People

Contributors

ccampbell avatar wesleytodd avatar

Watchers

 avatar  avatar  avatar

Forkers

captemulation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.