All Projects → nikku → jquery-controls

nikku / jquery-controls

Licence: other
Registration of ajax handlers to bind to certain elements of a page

Programming Languages

javascript
184084 projects - #8 most used programming language

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>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].