Registration of ajax handlers to bind to certain elements of a page
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
README.md

README.md

jQuery controls

Small jQuery plugin which allows other jQuery plugins to register custom click controls on page elements.

Features

  • Offers $.fn.controls.bindings as an entry point for other jQuery plugins to add custom click controls

Requirements

  • jQuery (tested with jQuery >= 1.4.2 but might work with earlier versions)

Usage

Include requirements and plugin in the header of your website

<html>
    <head>
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
        <script type="text/javascript" src="jquery.controls.js"></script>
    </head>
    <!-- ... -->

Register controls for a certain element, e.g. a link with .ajax as class

<script type="text/javascript">
    $.extend($.fn.controls.bindings, {
        "a.ajax": function(event) {
            alert("Won't trigger original click: Is an AJAX link!");
            event.preventDefault();
        }
    });
</script>

Execute .controls() on an element to bind all matching triggers to it

<script type="text/javascript">
    // Wait for page load
    $(function() {
        // Bind to document
        $(document).controls();
    });
</script>