Knockback.js Documentation

Download

You can download the Development Version or the Production Version. Both versions are currently provided under both MIT License and CC0 Public Domain Dedication.

Creating a new Class: new Knockback()

To create a new Class type, invoke new Knockback():

new Knockback(String className, Object methods, [String nativeElementToExtend])

This method returns the constructor to the newly created Class. It is not always necessary to save the constructor since it is also stored inside Knockback.js during runtime. Within methods, there are four special callbacks you can specify:

  1. Func created is invoked when a new instance of the Class is created. You can use this method to initialize variables, attributes, styles and innerHTML.
  2. Func attached is invoked when an instance is attached to document.
  3. Func detached is invoked when an instance is dettached to document.
  4. Func attrChange(String attributeName, Any previousValue, Any newValue) is invoked when an attribute is changed.

Note: Since className must internally contain at least one - character, Knockback.js will automatically convert a className that does not have - into one that does. As an example, myInputField will be converted into a <my-input-field>.

Creating a new Element: new Knockback.element()

To create a new Element, invoke new Knockback.element():

new Knockback.element(String className, Object attributes)

This method returns the constructor to the newly created Class. It is not always necessary to save the constructor since it is also stored inside Knockback.js during runtime. Within methods, there are four special callbacks you can specify:

  1. Func created is invoked when a new instance of the Class is created. You can use this method to initialize variables, attributes, styles and innerHTML.
  2. Func attached is invoked when an instance is attached to document.
  3. Func detached is invoked when an instance is dettached to document.
  4. Func attr(String attributeName, Any attributeValue) is invoked when an attribute is changed.