forked from nyarly/NinjaScript
-
Notifications
You must be signed in to change notification settings - Fork 1
In A Host Page
nyarly edited this page Sep 6, 2011
·
13 revisions
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+). When using NinjaScript, you’ll need to issue your configurations inside a Ninja.orders(callback)
call, at which point, the following calls become available:
- Ninja.configure( configurationObject)
- Adds settings to Ninjascript’s configuration. The object is just keys and values to be merged with the existing settings. Details about configuration settings can be found in Configuration
- 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 aftergo()
will fail. If you forget, there’s ago()
call triggered by the documentReady event. Callinggo()
sooner than that will result in more responsive page behavior. - Ninja.fireMutationEvent()
- Triggers a document wide scan for new elements for those browsers that don’t support any variant of DOM Mutation Events (Internet Explorer.) Generally, when you change the document using Javascript, you should call this method.