You can download the Development Version or the Production Version. Both versions are currently provided under both MIT License and CC0 Public Domain Dedication.
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:
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.Func attached
is invoked when an instance is attached to document.Func detached
is invoked when an instance is dettached to document.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>
.
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:
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.Func attached
is invoked when an instance is attached to document.Func detached
is invoked when an instance is dettached to document.Func attr(String attributeName, Any attributeValue)
is invoked when an attribute is changed.