forked from nyarly/NinjaScript
-
Notifications
You must be signed in to change notification settings - Fork 1
BehaviorAnatomy
Judson edited this page Jul 5, 2011
·
3 revisions
NinjaScript applies “behaviors” to elements selected using jQuery’s CSS-like selectors. A behavior consists of three things:
- A transformer: a function called “transform” that take the element as its argument, and changes it in ways that are appropriate to the behavior. One prepackaged behavior “make_ajax_link” takes a form consisting of a single submit button and converts it into an anchor tag with appropriate attributes.
- A list of event handlers – functions in two arguments that take action based on the event and the element. By default, NinjaScript event handlers swallow the event, preventing the default behavior and preventing the event from bubbling back up the DOM. You can use an array of [handler_function, *strings] to have NinjaScript allow “default” behavior, allow the event to “propagate”, or allow the “immediate” propagation of the event (to other handlers on the same element).
- A list of helper methods, which are available to the event handlers.