< documentation
Plugins
Extension Points
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.
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", { selector : 'a', event : 'click', strategy : 'first', routerKeys : 'urls', hijaxKey : 'link', eventNamespace : "Claypool:MVC:HijaxLinkController", target : function(event){ var link = event.target||event.currentTarget; while(link.tagName.toUpperCase()!='A'){ link = $(link).parent()[0]; } return $(link).attr("href"); } }).router( "hijax:button",{ selector : ':button', event : 'click', strategy : 'all', routerKeys : 'urls', hijaxKey : 'button', eventNamespace : "Claypool:MVC:HijaxButtonController", target : function(event){ return event.target.value; } }).router( "hijax:input",{ selector : 'input', event : 'click', strategy : 'all', routerKeys : 'urls', hijaxKey : 'input', eventNamespace : "Claypool:MVC:HijaxInputController", target : function(event){ return event.target.name; } }).router( "hijax:form",{ selector : 'form', event : 'submit', strategy : 'first', routerKeys : 'urls', hijaxKey : 'form', eventNamespace : "Claypool:MVC:HijaxFormController", target : function(event){ return event.target.action; } }).router( "hijax:event",{ strategy : 'all', routerKeys : 'event', hijaxKey : 'event', eventNamespace : "Claypool:MVC:HijaxEventController", target : function(event){ return event.type; } });
Project
- app
- app/boot
- app/boot/client.js
- app/boot/server.js
- app/configs
- app/configs/config.js
- app/configs/environments.js
- app/configs/filters.js
- app/configs/logging.js
- app/configs/routes.js
- app/controllers
- app/controllers/example.js
- app/models
- app/models/example.js
- app/services
- app/services/example.js
- app/templates
- app/templates/example.js
- app/views
- app/views/example.js
- index.html
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.