< documentation

router 1.0.x

usage

Creates a new low level router.
Routers are the heart of jquery.claypool. They provide clear, simple hijax patterns that sit between the browser and your application allowing all relevant events to be registered to a handful of routers that can delegate the events based on powerful regular expressions to your dormant application controllers using common or custom strategies, like first(tcp) and all(udp). Routers are a well known and popular framework tool to simplify application development.

options

id String
A unique name for this router.
options Object
A hash of router options.

Options:
Name Type
selector String
An optional jQuery selector, if none is present the router is bound to the document
event String
required for all but a pure event router, the event specifies the type of event the router binds to (eg 'click')
stratgey String Default: 'all'
Currently supports 'first' and 'all'
routerKeys String
A pipe delimited list of properties that will be checked in the router configuration to match against the target
hijaxKey String
a human readable name used to log the hijax event
eventNamespace String
An event namespace so the router can be cleanly unbound without interfering with other event bindings
target Function
This is the delegation function so you can bind a router to, for example, a table but return the delegated target (eg a td)

examples

This example illustrates the use of the router plugin by showing how jquery.claypool defines it's built in routers. See routes.js for more information on how to use routers.

    $.router( "hijax:a", &#x7B;
        selector        : 'a',
        event           : 'click',
        strategy        : 'first',
        routerKeys      : 'urls',
        hijaxKey        : 'link',
        eventNamespace  : "Claypool:MVC:HijaxLinkController",
        target       : function(event)&#x7B; 
            var link = event.target||event.currentTarget;
            while(link.tagName.toUpperCase()!='A')&#x7B;
                link = $(link).parent()[0];
            }
            return $(link).attr("href");
        }
    }).router( "hijax:button",&#x7B;
        selector        : ':button',
        event           : 'click',
        strategy        : 'all',
        routerKeys      : 'urls',
        hijaxKey        : 'button',
        eventNamespace  : "Claypool:MVC:HijaxButtonController",
        target       : function(event)&#x7B; 
            return event.target.value;
        }
    }).router( "hijax:input",&#x7B;
        selector        : 'input',
        event           : 'click',
        strategy        : 'all',
        routerKeys      : 'urls',
        hijaxKey        : 'input',
        eventNamespace  : "Claypool:MVC:HijaxInputController",
        target       : function(event)&#x7B; 
            return event.target.name;
        }
    }).router( "hijax:form",&#x7B;
        selector        : 'form',
        event           : 'submit',
        strategy        : 'first',
        routerKeys      : 'urls',
        hijaxKey        : 'form',
        eventNamespace  : "Claypool:MVC:HijaxFormController",
        target       : function(event)&#x7B; 
            return event.target.action;
        }
    }).router( "hijax:event",&#x7B;
        strategy        : 'all',
        routerKeys      : 'event',
        hijaxKey        : 'event',
        eventNamespace  : "Claypool:MVC:HijaxEventController",
        target       : function(event)&#x7B; 
            return event.type;
        }
    });
        
router releases

Project

Guides

This guide is applicable to both the jquery-claypool client and server application frameworks. Where the two differ functionally the documentation will provide notes and examples of usage in each environment.