Bind Mixin
Description
This mixin used jQuery bind to connect java/javascript objects to jQuery events. Bind is easily subclassed to allow more than one event per element.
Links
Name | Required | Java Type | Default Prefix | Default Value | Description |
---|---|---|---|---|---|
element | false | String | literal | getClientId() | Used as the selector for jQuery bind. |
context | false | Object[] | prop | none | The context used to construct the event link. |
title | false | String | literal | none | When an event is triggered the page title is changed to this value. |
history | false | String | literal | none | Javascript anonymous function called by the event. Used to manage history on the browser. Signature is history(event,ui,url). The parameter types are identical to callback. |
eventType | false | String | literal | this.getClass().getSimpleName().toLowerCase() | Name of the jQuery event. By subclassing bind you can create mixins named by the jQuery event type. This allows more than one event per element. |
preventDefault | false | Boolean | prop | true | If true calls event.preventDefault(). |
doImports | false | Boolean | prop | true | If true bind will attempt to include the right effect libraries for zone and hide. |
contextMarker | false | String | literal | CoNtExT | Used as a marker by url.addContext() to insert values into the Tapestry event url. |
event | false | String | literal | none | Tapestry event name. For example if you supply click onClick() will be called. |
hide | false | String | literal | none | ID of element to hide on this event. |
hideEffect | false | String | literal | slide | jQuery effect used to hide the element. |
hideTime | false | String | literal | 500 | Duration of hide effect. |
hideOption | false | Map<String, String> | prop | none | Any options need by the hide effect. |
zone | false | String | literal | none | If supplied a zone update will be triggered. |
zoneUpdate | false | String | literal | highlight | Effect used when zone is updating. |
callback | false | String | literal | none | Javascript anonymous function called by the event. The signature is function(event,ui,url) where event and ui are described by jQuery bind. The url parameter is structure representing the Tapestry event url and contains the url and a function to add a context. See examples below. |
How to Bind just a JavaScript event ?
With the Bind mixin, we can catch JavaScript events in your Java Class. Tapestry-jQuery will trigger an Ajax Request. In this example, I will bind the slidechange event of the slider widget
Zone for the SlideChange event :