Skip to content
Judson edited this page Jul 7, 2011 · 13 revisions

Back to the Reference

Ninjascript is intended to be used primarily within a host HTML document. ninjascript.js or ns.min.js needs to be included, after jQuery (version 1.4+), at which point, the following calls become available:

Ninja.behavior( behaviorObject )
The behavior object should have CSS selectors as keys (they’re parsed by Sizzle 1.0) and behavior resolvable objects as values. Once Ninjascript starts, any element that matches a selector will have the appropriate behavior applied. Note that multiple behaviors might apply to an element: this is by design.
Ninja.go()
This method lets Ninjascript know that you’re done defining behaviors and it should start applying those definitions. There’s nothing wrong with Ninja.go() being called more than once, but .behavior() calls after go() will fail. If you forget, there’s a go() call triggered by the documentReady event. Calling go() sooner than that will result in more responsive page behavior.
Clone this wiki locally