Knockback.js API and Usage Examples

kb.FormattedObservable

Used to reformat a string when an argument changes. The format string can also be an observable.

Example:

formatted_name = kb.formattedObservable("{1}...cool!", kb.observable(model, 'name'))
var formatted_name = kb.formattedObservable("{1}...cool!", kb.observable(model, 'name'));

kb.formattedObservable(format, args...) factory

Used to create a new instance

Parameters
  1. format:a format string such as "{0} and {1}" where {0} and {1} would be synchronized with the arguments (eg. "Bob and Carol" where {0} is Bob and {1} is Carol)
  2. args:all arguments to be passed to the kb.LocaleManager's get() method

Example:

formatted_name = kb.formattedObservable("{1}...cool!", kb.observable(model, 'name'))

constructor(format, args...) observable returned

Used to create a new instance

Parameters
  1. format: a format string such as "{0} and {1}" where {0} and {1} would be synchronized with the arguments (eg. "Bob and Carol" where {0} is Bob and {1} is Carol)
  2. args: all arguments to be passed to the kb.LocaleManager's get() method

Example:

formatted_name = new kb.FormattedObservable("{1}...cool!", kb.observable(model, 'name'))
var formatted_name = new kb.FormattedObservable("{1}...cool!", kb.observable(model, 'name'));

destroy()

Used to release the memory of the object